Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Ilia Alshanetsky
While you are correct that invalid offset in a string will produce an error message. This error message is E_NOTICE, given that our default INI error reporting level won't display those it's arguable that very few people will see them and consequently do something about it. > echo $a{strlen($a)

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Alan Knowles
echo $a{strlen($a)-1}; ? is that really that bad. I do worry that at present $a = "a string"; $p = 0 while( $p < strlen($p) ) .. do stuff that could do $p-- or $p++ echo $a{$p}; } at present that would produce a nice error if you went < 0.. easy to spot.. - if -ve was supported it could d

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Robert Cummings
On Fri, 2004-10-29 at 19:31, Derick Rethans wrote: > On Fri, 29 Oct 2004, Robert Cummings wrote: > > > On Fri, 2004-10-29 at 19:04, Derick Rethans wrote: > > > > > Yeah, [] is for arrays, {} for string indexes though I still think this > > > should not be in, one can use substring for this. Someth

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Derick Rethans
On Fri, 29 Oct 2004, Robert Cummings wrote: > On Fri, 2004-10-29 at 19:04, Derick Rethans wrote: > > > Yeah, [] is for arrays, {} for string indexes though I still think this > > should not be in, one can use substring for this. Something like a > > "negative string index" is IMO too much magic. >

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Robert Cummings
On Fri, 2004-10-29 at 19:04, Derick Rethans wrote: > On Fri, 29 Oct 2004, Sterling Hughes wrote: > > > why not add it with the {} operators then? > > Yeah, [] is for arrays, {} for string indexes though I still think this > should not be in, one can use substring for this. Something like a > "neg

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Derick Rethans
On Fri, 29 Oct 2004, Sterling Hughes wrote: > why not add it with the {} operators then? Yeah, [] is for arrays, {} for string indexes though I still think this should not be in, one can use substring for this. Something like a "negative string index" is IMO too much magic. Derick -- Derick Re

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Andi Gutmans
t;[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 29, 2004 3:07 PM Subject: [PHP-DEV] Negative string offset support > I am wondering what are people's opinions on adding support for negative > string offsets that could be used to access data from the end of a string

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Paul G
- Original Message - From: "Ilia Alshanetsky" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, October 29, 2004 3:07 PM Subject: [PHP-DEV] Negative string offset support > I am wondering what are people's opinions on adding support for negative

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Ilia Alshanetsky
Sure, I have no operator preference. Ilia Sterling Hughes wrote: why not add it with the {} operators then? -sterling On Fri, 29 Oct 2004 15:07:05 -0400, Ilia Alshanetsky <[EMAIL PROTECTED]> wrote: I am wondering what are people's opinions on adding support for negative string offsets that could be

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Rasmus Lerdorf
Right, I was about to say that too. If we only did it for the {} operator it would encourage people to use that little-used operator thereby removing a source of confusion and at the same time the BC issues are minimal. -Rasmus On Fri, 29 Oct 2004, Sterling Hughes wrote: > why not add it with t

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread cm
Exactly what I thought when reading the original post :) - Michael > why not add it with the {} operators then? > > -sterling > > > On Fri, 29 Oct 2004 15:07:05 -0400, Ilia Alshanetsky <[EMAIL PROTECTED]> > wrote: >> I am wondering what are people's opinions on adding support for negative >> stri

Re: [PHP-DEV] Negative string offset support

2004-10-29 Thread Sterling Hughes
why not add it with the {} operators then? -sterling On Fri, 29 Oct 2004 15:07:05 -0400, Ilia Alshanetsky <[EMAIL PROTECTED]> wrote: > I am wondering what are people's opinions on adding support for negative > string offsets that could be used to access data from the end of a string. > > Ex. $a

[PHP-DEV] Negative string offset support

2004-10-29 Thread Ilia Alshanetsky
I am wondering what are people's opinions on adding support for negative string offsets that could be used to access data from the end of a string. Ex. $a = "123"; echo $a[-1]; // would print 3 I don't think we should do this for arrays, since -1 and similar are valid array keys, which means add