On Mon, 20 Jun 2011, Robert Eisele wrote:

> 2011/6/20 Derick Rethans <der...@php.net>
> 
> > On Mon, 20 Jun 2011, 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.
> >
> > > If you want to implement a parser in PHP, you have to go the way 
> > > with for + strlen + substr() or $x[$i] to address one character of 
> > > the string.
> >
> > Yes, this sounds like a good addition to me. One question though, 
> > what to do with an object that implements __toString() ?
> >
> 
> That's the question, maybe one must force __toString() via an explicit 
> string-cast:
> 
> foreach( (string) $obj as $k=>$v)

That's a sensible thing indeed. We just need to make sure we document 
this with an example and a test then.

cheers,
Derick

-- 
http://derickrethans.nl | http://xdebug.org
Like Xdebug? Consider a donation: http://xdebug.org/donate.php
twitter: @derickr and @xdebug

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to