Re: [PHP-DEV] Re: foreach() for strings

2011-06-21 Thread Derick Rethans
On Mon, 20 Jun 2011, Anthony Ferrara wrote: > > text_to_array($s) == str_split($s, 1) > > No, because str_split always splits into 1 byte chunks. text_to_array > would take the character set into account (or that's where the utility > in it would be)... No, as PHP currently does *NOT* know abou

Re: [PHP-DEV] Re: foreach() for strings

2011-06-21 Thread Stas Malyshev
Hi! On 6/21/11 1:23 AM, Ferenc Kovacs wrote: 2011/6/21 Robert Eisele mailto:rob...@xarg.org>> And what actually failed? The idea seams straightforward. Robert http://www.slideshare.net/andreizm/the-good-the-bad-and-the-ugly-what-happened-to-unicode-and-php-6 Also you may want to r

Re: [PHP-DEV] Re: foreach() for strings

2011-06-21 Thread Ferenc Kovacs
2011/6/21 Robert Eisele > And what actually failed? The idea seams straightforward. > > Robert > > http://www.slideshare.net/andreizm/the-good-the-bad-and-the-ugly-what-happened-to-unicode-and-php-6 to my understanding: in retrospective the utf-16 wasn't the best idea, it caused more conversion

Re: [PHP-DEV] Re: foreach() for strings

2011-06-21 Thread Robert Eisele
And what actually failed? The idea seams straightforward. Robert 2011/6/20 Johannes Schlüter > On Mon, 2011-06-20 at 20:38 +0200, Robert Eisele wrote: > > I really like the ideas shared here. It's a thing of consideration that > > array-functions should also work with strings. Maybe this would

Re: [PHP-DEV] Re: foreach() for strings

2011-06-20 Thread Johannes Schlüter
On Mon, 2011-06-20 at 20:38 +0200, Robert Eisele wrote: > I really like the ideas shared here. It's a thing of consideration that > array-functions should also work with strings. Maybe this would be the way > to go, but I'm more excited about the OOP implementation of TextIterator and > ByteIterato

Re: [PHP-DEV] Re: foreach() for strings

2011-06-20 Thread Tomas Kuliavas
2011.06.20 21:38 Robert Eisele rašė: > I really like the ideas shared here. It's a thing of consideration that > array-functions should also work with strings. Maybe this would be the way > to go, but I'm more excited about the OOP implementation of TextIterator > and > ByteIterator, which solves t

RE: [PHP-DEV] Re: foreach() for strings

2011-06-20 Thread John Crenshaw
> -Original Message- > From: Anthony Ferrara [mailto:ircmax...@gmail.com] > > > text_to_array($s) == str_split($s, 1) > > No, because str_split always splits into 1 byte chunks. text_to_array > would take the character set into account (or that's where the utility > in it would be)...

Re: [PHP-DEV] Re: foreach() for strings

2011-06-20 Thread Robert Eisele
I really like the ideas shared here. It's a thing of consideration that array-functions should also work with strings. Maybe this would be the way to go, but I'm more excited about the OOP implementation of TextIterator and ByteIterator, which solves the whole problem at once (and is easier to impl

Re: [PHP-DEV] Re: foreach() for strings

2011-06-20 Thread Todd Ruth
On Mon, 2011-06-20 at 10:06 -0700, Stas Malyshev wrote: > Hi! > > On 6/20/11 9:57 AM, Todd Ruth wrote: > > Iterators are nice. Having a "text_string_to_array" function > > would also be fine. For example: > > > > $s = 'hello'; > > foreach (text_string_to_array($s) as $x) { > > var_dump($x);

Re: [PHP-DEV] Re: foreach() for strings

2011-06-20 Thread Anthony Ferrara
> text_to_array($s) == str_split($s, 1) No, because str_split always splits into 1 byte chunks. text_to_array would take the character set into account (or that's where the utility in it would be)... On Mon, Jun 20, 2011 at 1:06 PM, Stas Malyshev wrote: > Hi! > > On 6/20/11 9:57 AM, Todd Ruth

Re: [PHP-DEV] Re: foreach() for strings

2011-06-20 Thread Stas Malyshev
Hi! On 6/20/11 9:57 AM, Todd Ruth wrote: Iterators are nice. Having a "text_string_to_array" function would also be fine. For example: $s = 'hello'; foreach (text_string_to_array($s) as $x) { var_dump($x); } text_to_array($s) == str_split($s, 1) -- Stanislav Malyshev, Software Archit

[PHP-DEV] Re: foreach() for strings

2011-06-20 Thread Todd Ruth
Adding to John Crenshaw's list of reasons not to implicitly treat strings as arrays in foreach loops... Please keep in mind the following valid code: $s = 'hello'; foreach ((array)$s as $x) { var_dump($x); } The result is: string(5) "hello" That behavior can be handy. Hopefully, a BC break