Re: [PHP] slicing and dicing strings

2012-06-28 Thread Geoff Shang

On Wed, 27 Jun 2012, tamouse mailing lists wrote:


RTFM with no hint of where to look is a problem. But the dictum of
Read here in the manual will surely be the best thing. You will then
know where to look for future questions.


Personally, I've got better things to do with my time than spend it 
committing the syntax and semantics of every single PHP function to 
memory.  I nearly always have the php.net front page with its function 
search open in a browser whenever I'm writing something more than a few 
lines.  The function search seriously rocks.  Even if I can't remember 
which string function I want, I can search for *any* string function and 
I'll get the list of all of them, along with a quick summary to help me 
find the one I want.


Geoff.


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] slicing and dicing strings

2012-06-28 Thread admin
-Original Message-
From: Geoff Shang [mailto:ge...@quitelikely.com] 
Sent: Thursday, June 28, 2012 5:12 AM
To: php-general@lists.php.net
Subject: Re: [PHP] slicing and dicing strings

On Wed, 27 Jun 2012, tamouse mailing lists wrote:

 RTFM with no hint of where to look is a problem. But the dictum of 
 Read here in the manual will surely be the best thing. You will then 
 know where to look for future questions.

Personally, I've got better things to do with my time than spend it
committing the syntax and semantics of every single PHP function to memory.
I nearly always have the php.net front page with its function search open in
a browser whenever I'm writing something more than a few lines.  The
function search seriously rocks.  Even if I can't remember which string
function I want, I can search for *any* string function and I'll get the
list of all of them, along with a quick summary to help me find the one I
want.

Geoff.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
---

Geoff,
The function you are looking for is SUBSTR();
I understand you have the manual open and you think you can find the answer
pretty quickly.
Please understand that knowing a little, to advanced features of all
functions will help you significantly.
It will cut down on research time and you have a better understanding of
what function will better fit 
the situation at hand. While some people will never fully remember all
syntax of every function it never hurt 
anyone in attempting to understand a majority of PHP functionality.

:)
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Can I do this in a single match/replace?

2012-06-28 Thread Ford, Mike
 -Original Message-
 From: Paul Halliday [mailto:paul.halli...@gmail.com]
 Sent: 28 June 2012 02:27

 
 Using preg_match and this pattern I can get the refs:
 
 $pattern = '\reference:url,([^;]+;)\';
 
 which gives me:
 
 $matches[0] = www.ndmp.org/download/sdk_v4/draft-skardal-ndmp4-
 04.txt
 $matches[1] = doc.emergingthreats.net/bin/view/Main/2002068
 
 now what I would like to do is replace inline adding a
 href=http://;
 . $matches[n] .  . $matches[n] . /a
 
 Can this be done or do I need to say loop through matches (there can
 be none or many) and do a str_replace.

$new_string = preg_replace($pattern, 'a href=http://$1;$1/a' , 
$string);

should do it -- don't *think* you need any pesky \ escapes in the
replacement, but could be wrong on that one, so please suck it and
see...

Cheers!

Mike

-- 
Mike Ford,
Electronic Information Developer, Libraries and Learning Innovation,  
Portland PD507, City Campus, Leeds Metropolitan University,
Portland Way, LEEDS,  LS1 3HE,  United Kingdom 
E: m.f...@leedsmet.ac.uk T: +44 113 812 4730





To view the terms under which this email is distributed, please go to 
http://disclaimer.leedsmet.ac.uk/email.htm

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: slicing and dicing strings

2012-06-28 Thread Shailesh N. Humbad

On 6/27/2012 6:15 PM, Kirk Bailey wrote:

ok, it slices and dices, but how?
in python, to print all but the last char in string FOO, we say
print FOO[:-1]
But this seems to bark like a basset hound in php. Whyfore?

Now tihs tyro is seeking sage words to help me understand this.
RTFM is not sage words; if you don't want to help me please don't waste
the bandwidth.

Would anyone care to help me understand this without dedicating 4
precious and in over demand/under supply hours to RTFM?



print substr($foo, 0, -1);

You could also do this, but it takes more code:
print substr($foo, 0, strlen($foo) - 1);

You could wrap it as a function like so:
function strchop($string, $num_chars_to_chop_off_end)
{
return substr($string, 0, -$num_chars_to_chop_off_end);
}

If you have time, the relevant manual page is:
http://www.php.net/manual/en/function.substr.php




--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: slicing and dicing strings

2012-06-28 Thread Ian


 RTFM is not sage words; if you don't want to help me please don't waste
 the bandwidth.


Hi,

Seeing as you are using Windows, why not download the manual as a handy
Windows Help File (CHM), that way you wont waste bandwidth online every
time you get stumped.

http://www.php.net/download-docs.php

I recommend the version with user notes as there are also lots of great
examples / comments included too.


There are also CHM readers for other operating systems (including
mobiles), so no excuse for not Reading The Fine Manual any more.

Regards

Ian
-- 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] php batch/queue framwork

2012-06-28 Thread Tom Sparks
I am looking for a batch/queue framework that is database-centric?
I could write my own, but I want one that is mature

tom_a_sparks
It's a nerdy thing I like to do



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] slicing and dicing strings

2012-06-28 Thread Daniel Brown
On Wed, Jun 27, 2012 at 6:15 PM, Kirk Bailey kbai...@howlermonkey.net wrote:
 ok, it slices and dices, but how?
 in python, to print all but the last char in string FOO, we say
 print FOO[:-1]
 But this seems to bark like a basset hound in php. Whyfore?

It is a longer syntax which, in agreement with some folks, I think
could be shortened (there's a feature request you could submit if you
were so inclined), but there's a few methods you could use.  Two of
which are shown below.

?php
$foo = 'This seems to bark like a basset hound in PHP';

echo $foo{(strlen($foo) - 1)};
echo substr($foo,-1);
?

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Depreciation message I can't make out....

2012-06-28 Thread Gary Lebowitz
Hi,

I am running Moodle 2.2.3 and using PHP 5.3 on a Linux server with GoDaddy
and am getting the message about depreciation after having typed the
following command into their cron job manager:
 /web/cgi-bin/php5_3 $HOME/html/moodle223a/admin/cli/cron.php

 PHP Deprecated:  Comments starting with '#' are deprecated in
/web/conf/php5.ini on line 1256 in Unknown on line 0
PHP Deprecated:  Comments starting with '#' are deprecated in
/web/conf/php5.ini on line 1257 in Unknown on line 0
br /
bDeprecated/b:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3
and greater in bUnknown/b on line b0/bbr /
Content-type: text/html

GoDaddy says that I am using a command that is not adapted to version 5.3
of PHP, but they suggested I contact you to fix it. Also, I do not believe
I have access to php5.ini; only they do. But I would need to tell them how
to fix this issue. And no one at Moodle.org seems to be able to help.
Perhaps it's a Moodle thing; perhaps not, but I thought it wise to contact
you. By the way, this message is only sent to me when using version 5.3 of
PHP; I have another Moodle site using 5.2 and things go perfectly well,
without this message.

Regards,


[PHP] Re: Depreciation message I can't make out....

2012-06-28 Thread Jim Giner

Gary Lebowitz gurqi...@gmail.com wrote in message 
news:cafbvbik1ga9eyxkstpshxk+ddfax0fqoy-gnpdymfl_26_g...@mail.gmail.com...
 Hi,

 I am running Moodle 2.2.3 and using PHP 5.3 on a Linux server with GoDaddy
 and am getting the message about depreciation after having typed the
 following command into their cron job manager:
 /web/cgi-bin/php5_3 $HOME/html/moodle223a/admin/cli/cron.php

 PHP Deprecated:  Comments starting with '#' are deprecated in
 /web/conf/php5.ini on line 1256 in Unknown on line 0
 PHP Deprecated:  Comments starting with '#' are deprecated in
 /web/conf/php5.ini on line 1257 in Unknown on line 0
 br /
 bDeprecated/b:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3
 and greater in bUnknown/b on line b0/bbr /
 Content-type: text/html

 GoDaddy says that I am using a command that is not adapted to version 5.3
 of PHP, but they suggested I contact you to fix it. Also, I do not believe
 I have access to php5.ini; only they do. But I would need to tell them how
 to fix this issue. And no one at Moodle.org seems to be able to help.
 Perhaps it's a Moodle thing; perhaps not, but I thought it wise to contact
 you. By the way, this message is only sent to me when using version 5.3 of
 PHP; I have another Moodle site using 5.2 and things go perfectly well,
 without this message.

 Regards,


It's deprecated, not depreciated.  That said - magic quotes were marked 
for deprecation a while ago, so you should be prepared to stop expecting 
them in your appls.  As for the # sign, apparently it is no longer a valid 
char for comments (deprecated).  Remove the magci quotes setting and change 
your # chars to // or whatever pleases you for your comments. 



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Depreciation message I can't make out....

2012-06-28 Thread Camilo Sperberg
According to what i can understand from that message is that you have line(s) 
starting with # in your php.ini file. A proper ini file should use ; as the 
beginning from a comment. 

Check the given file at the given line and change the first # symbol into a ; 
one. 

Greetings. 

Sent from my iPhone 5 Beta [Confidential use only]

On 28 jun. 2012, at 19:44, Gary Lebowitz gurqi...@gmail.com wrote:

 Hi,
 
 I am running Moodle 2.2.3 and using PHP 5.3 on a Linux server with GoDaddy
 and am getting the message about depreciation after having typed the
 following command into their cron job manager:
 /web/cgi-bin/php5_3 $HOME/html/moodle223a/admin/cli/cron.php
 
 PHP Deprecated:  Comments starting with '#' are deprecated in
 /web/conf/php5.ini on line 1256 in Unknown on line 0
 PHP Deprecated:  Comments starting with '#' are deprecated in
 /web/conf/php5.ini on line 1257 in Unknown on line 0
 br /
 bDeprecated/b:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3
 and greater in bUnknown/b on line b0/bbr /
 Content-type: text/html
 
 GoDaddy says that I am using a command that is not adapted to version 5.3
 of PHP, but they suggested I contact you to fix it. Also, I do not believe
 I have access to php5.ini; only they do. But I would need to tell them how
 to fix this issue. And no one at Moodle.org seems to be able to help.
 Perhaps it's a Moodle thing; perhaps not, but I thought it wise to contact
 you. By the way, this message is only sent to me when using version 5.3 of
 PHP; I have another Moodle site using 5.2 and things go perfectly well,
 without this message.
 
 Regards,

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Depreciation message I can't make out....

2012-06-28 Thread Daniel Brown
On Thu, Jun 28, 2012 at 1:44 PM, Gary Lebowitz gurqi...@gmail.com wrote:
 Hi,

 I am running Moodle 2.2.3 and using PHP 5.3 on a Linux server with GoDaddy
 and am getting the message about depreciation after having typed the
 following command into their cron job manager:
  /web/cgi-bin/php5_3 $HOME/html/moodle223a/admin/cli/cron.php

  PHP Deprecated:  Comments starting with '#' are deprecated in
 /web/conf/php5.ini on line 1256 in Unknown on line 0
 PHP Deprecated:  Comments starting with '#' are deprecated in
 /web/conf/php5.ini on line 1257 in Unknown on line 0
 br /
 bDeprecated/b:  Directive 'magic_quotes_gpc' is deprecated in PHP 5.3
 and greater in bUnknown/b on line b0/bbr /
 Content-type: text/html

Comment-out, using semicolons (;), any comments in your
/web/conf/php5.ini file that begin with the hashmark (#), and then
also comment-out (;) the magic_quotes_gpc line.

 GoDaddy says that I am using a command that is not adapted to version 5.3
 of PHP, but they suggested I contact you to fix it. Also, I do not believe
 I have access to php5.ini; only they do. But I would need to tell them how
 to fix this issue. And no one at Moodle.org seems to be able to help.
 Perhaps it's a Moodle thing; perhaps not, but I thought it wise to contact
 you. By the way, this message is only sent to me when using version 5.3 of
 PHP; I have another Moodle site using 5.2 and things go perfectly well,
 without this message.

That's typical of GoDaddy.  Not only will they do nothing about it
(if they are even able to figure it out), but they'll give you bad
advice.  This is a public peer-support mailing list.  We cannot (and
will not) fix things for people.  Further, if GoDaddy is responsible
for the maintenance of the machine (and they probably are, as I
presume it's a shared hosting environment), they need to fix it.
They're the ones who screwed it up in the first place.

-- 
/Daniel P. Brown
Network Infrastructure Manager
http://www.php.net/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Re: php batch/queue framwork

2012-06-28 Thread Shailesh N. Humbad

On 6/28/2012 11:58 AM, Tom Sparks wrote:

I am looking for a batch/queue framework that is database-centric?
I could write my own, but I want one that is mature

tom_a_sparks
It's a nerdy thing I like to do




You could try Amazon Simple Queue Service: http://aws.amazon.com/sqs/
Use the PHP SDK: http://aws.amazon.com/sdkforphp/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] Is there a way to customize the 'Username' and 'Password' strings in a 401 auth dialog box?

2012-06-28 Thread Daevid Vincent
Is there a way to customize the 'Username' and 'Password' strings in a 401
auth dialog box?
 
I want to change mine to say Webmaster ID and Authentication Key.
 
http://php.net/manual/en/features.http-auth.php
 


Re: [PHP] Depreciation message I can't make out....

2012-06-28 Thread tamouse mailing lists
On Thu, Jun 28, 2012 at 1:00 PM, Daniel Brown danbr...@php.net wrote:
  PHP Deprecated:  Comments starting with '#' are deprecated in
 /web/conf/php5.ini on line 1256 in Unknown on line 0

    Comment-out, using semicolons (;), any comments in your
 /web/conf/php5.ini file that begin with the hashmark (#), and then
 also comment-out (;) the magic_quotes_gpc line.

Just a quick followup -- # comments are deprecated for .ini files,
only, correct? They are still full citizens in php source, aren't
they?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What's happened to our newsgroup?

2012-06-28 Thread tamouse mailing lists
On Wed, Jun 27, 2012 at 9:42 AM, Tedd Sperling t...@sperling.com wrote:
 On Jun 26, 2012, at 3:21 PM, Al n...@ridersite.org wrote:

 No postings for days.


 Maybe everyone learned it -- no new questions.

 Cheers,

 tedd

We now all have php.net open all the time so no more questions need to
be asked! :

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] What's happened to our newsgroup?

2012-06-28 Thread Daniel Fenn
Or everyone is on holiday for php :P






On Fri, Jun 29, 2012 at 10:43 AM, tamouse mailing lists
tamouse.li...@gmail.com wrote:
 On Wed, Jun 27, 2012 at 9:42 AM, Tedd Sperling t...@sperling.com wrote:
 On Jun 26, 2012, at 3:21 PM, Al n...@ridersite.org wrote:

 No postings for days.


 Maybe everyone learned it -- no new questions.

 Cheers,

 tedd

 We now all have php.net open all the time so no more questions need to
 be asked! :

 --
 PHP General Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] What's happened to our newsgroup?

2012-06-28 Thread Jay Blanchard

[snip]
We now all have php.net open all the time so no more questions need to 
be asked! :

[/snip]

You mean everyone finally RTFM?

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] Is there a way to customize the 'Username' and 'Password' strings in a 401 auth dialog box?

2012-06-28 Thread David OBrien
On Thu, Jun 28, 2012 at 7:23 PM, Daevid Vincent dae...@daevid.com wrote:

 Is there a way to customize the 'Username' and 'Password' strings in a 401
 auth dialog box?

 I want to change mine to say Webmaster ID and Authentication Key.

 http://php.net/manual/en/features.http-auth.php


This  http://www.ietf.org/rfc/rfc2617.txt says the browser actually
controls the prompts all you get to set is the realm.