That's why there is TextIterator. And it's also much faster (in PHP 6)
than iterating through string using indexes.
-Andrei
Stefan Walk wrote:
On Tuesday 17 June 2008 08:27:37 Arvids Godjuks wrote:
2008/6/16 Edward Z. Yang <[EMAIL PROTECTED]>:
PHP userland code may not treat strings as first class arrays, but
that's certainly how they are represented internally.
Anyway, it would be neat if we could get that foreach syntax to work. I
get sick of for($i = 0, $c = strlen($str); $i < $c; $i++) very quickly.
Totaly agree, the best example from the whole thread
You're not learning from the mistakes of other languages (ruby in this case,
which removed Enumerable from String in 1.9) ... "foreach" makes no sense for
strings, because it's unclear what you want (with unicode terminology here,
as this is for php6):
"for each byte" "for each codeunit" "for each codepoint", or "for each line",
or ... if you want to use foreach in your example, just do
foreach (str_split($str) as $value) { ...
Regards,
Stefan
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php