Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Johannes Schlüter
On Mon, 20 Jun 2011 18:27:48 +0200, Robert Eisele wrote: > 2011/6/20 Johannes Schlüter >> Yes. So having this in the current form accepted means that >> >>$a[-1]; >> >> can have two meanings: >> >>1) Get the last item (byte in a string) >>2) Get item `-1` (in an array) >> > > Yes, s

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Robert Eisele
2011/6/20 Stas Malyshev > Hi! > > Negative string offsets is a wish and also an implementation of my running >> PHP version for long. It operates in the same fashion like substr() with >> negative offsets, but avoids the function call and is much smarter if one >> single character has to be extr

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Stas Malyshev
Hi! Negative string offsets is a wish and also an implementation of my running PHP version for long. It operates in the same fashion like substr() with negative offsets, but avoids the function call and is much smarter if one single character has to be extracted: $str = "Hallo"; Sounds OK, bu

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Robert Eisele
2011/6/20 Johannes Schlüter > On Mon, 2011-06-20 at 17:49 +0200, Robert Eisele wrote: > > I would not consider this for arrays and objects, too. If we had real > > arrays, this would make sense but they are HT's and therewith it can also > be > > explained that -1 is an element and not the end of

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Johannes Schlüter
On Mon, 2011-06-20 at 17:49 +0200, Robert Eisele wrote: > I would not consider this for arrays and objects, too. If we had real > arrays, this would make sense but they are HT's and therewith it can also be > explained that -1 is an element and not the end of the chained list behind > the HT. Yes.

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Robert Eisele
I would not consider this for arrays and objects, too. If we had real arrays, this would make sense but they are HT's and therewith it can also be explained that -1 is an element and not the end of the chained list behind the HT. 2011/6/20 Johannes Schlüter > On Mon, 2011-06-20 at 16:31 +0200, E

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Robert Eisele
I would push this out in two steps. First: Negative string offset and later range/slice support for objects and strings. Objects would need a new magic method, e.g. "__slice()",strings need a substr() like interface. I think both are accessed the same way, but way are different. The slice support i

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Johannes Schlüter
On Mon, 2011-06-20 at 16:31 +0200, Etienne Kneuss wrote: > >> Negative string offsets is a wish and also an implementation of my running > >> PHP version for long. It operates in the same fashion like substr() with > >> negative offsets, but avoids the function call and is much smarter if one > >>

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Ilia Alshanetsky
+1, seems useful. On Mon, Jun 20, 2011 at 8:02 AM, Robert Eisele wrote: > Negative string offsets is a wish and also an implementation of my running > PHP version for long. It operates in the same fashion like substr() with > negative offsets, but avoids the function call and is much smarter if o

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Jordi Boggiano
On 20.06.2011 14:02, Robert Eisele wrote: > Negative string offsets is a wish and also an implementation of my running > PHP version for long. It operates in the same fashion like substr() with > negative offsets, but avoids the function call and is much smarter if one > single character has to be

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Etienne Kneuss
Hi, On Mon, Jun 20, 2011 at 14:05, Derick Rethans wrote: > On Mon, 20 Jun 2011, Robert Eisele wrote: > >> Negative string offsets is a wish and also an implementation of my running >> PHP version for long. It operates in the same fashion like substr() with >> negative offsets, but avoids the func

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Felipe Pena
Hi, 2011/6/20 Robert Eisele > Negative string offsets is a wish and also an implementation of my running > PHP version for long. It operates in the same fashion like substr() with > negative offsets, but avoids the function call and is much smarter if one > single character has to be extracted:

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Derick Rethans
On Mon, 20 Jun 2011, Robert Eisele wrote: > Negative string offsets is a wish and also an implementation of my running > PHP version for long. It operates in the same fashion like substr() with > negative offsets, but avoids the function call and is much smarter if one > single character has to be