Re: foreach() for strings

From: Date: Mon, 20 Jun 2011 12:09:23 +0000
Subject: Re: foreach() for strings
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-53397@lists.php.net to get a copy of this message
2011/6/20 Johannes Schlüter <johannes@schlueters.de>: > On Mon, 2011-06-20 at 13:27 +0200, Robert Eisele wrote: >> foreach() has many functions, looping over arrays, objects and implementing >> the iterator interface. I think it's also quite intuitive to use foreach() >> for strings, too. > > I would prefer a TextIterator as we had in the old PHP 6 as this allows > more powerful filtering etc. using iterator semantics even though this > might be a bit slower. A foreach with string should be seen as binary buffer, with no clue about its content and only to fetch it byte by byte. TextIterator can be smarter and support unicode when ICU is available. Cheers, -- Pierre @pierrejoye | http://blog.thepimp.net | http://www.libgd.org

« previous php.internals (#53397) next »