[PHP-DEV] Negative string offsets

2011-06-20 Thread 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: $str = Hallo; $str[0] == H $str[-1]

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

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Felipe Pena
Hi, 2011/6/20 Robert Eisele rob...@xarg.org 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 der...@php.net 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

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 Ilia Alshanetsky
+1, seems useful. On Mon, Jun 20, 2011 at 8:02 AM, Robert Eisele rob...@xarg.org 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

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 single

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 is

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 johan...@schlueters.de On Mon,

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. So

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Robert Eisele
2011/6/20 Johannes Schlüter johan...@schlueters.de 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

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, but

Re: [PHP-DEV] Negative string offsets

2011-06-20 Thread Robert Eisele
2011/6/20 Stas Malyshev smalys...@sugarcrm.com 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