On Mon, 2007-07-23 at 10:39 -0400, Nathan Nobbe wrote: > > On 7/23/07, Larry Garfield <larry@xxxxxxxxxxxxxxxx> wrote: > > Isn't that what garbage collection is for? > > well garbage collection will remove the copy of an array created by foreach, > but what Kevin > is saying is Iterators dont bother creating a copy of the array, which > overall results in memory > savings. Foreach doesn't bother creating a copy of the array either. It create COW handle. This wasn't true for objects in PHP4 but you're talking about arrays and if you're using iterators then you're also talking about PHP5 so no copy is being used. I don't know for certain, but I'd guess that Iterators are slower than foreach. Slower, but more convenient for some datatypes. Why do I think slower? Because if I'm not mistaken it invokes a userspace function/method on each iteration whereas foreach does not... don't quote me though, I don't use iterators since I write backward compatible scripts and so I haven't bothered to actually look at them. Cheers, Rob. -- ........................................................... SwarmBuy.com - http://www.swarmbuy.com Leveraging the buying power of the masses! ........................................................... -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php