This one time, at band camp, Jim Lucas <[EMAIL PROTECTED]> wrote:

> I don't get it, why not do this?

> foreach ( $array AS $row ) {
>       foreach ( $row AS $k => $v ) {
>               if ( ! is_array($v) ) {
>                       echo "{$k} -- {$v}<br/>\n";
>               }
>       }
> }

> 
> Maybe I am missing the point...  ???

Indeed, whilst your method is simplistic it leaves many copies of the array
dangling in memory. Every time you call foreach it creates a copy of the
array internally. SPL iterators do things differently and know only one
element at a time. More can be seen at 
http://phpro.org/tutorials/Introduction-to-SPL.html

so the final solution was using a foreach, however, using a foreach on an
SPL iterator object implicitly calls the inner iterator giving us all the
SPL goodness in memory savings.



Kind regards
Kevin



-- 
"Democracy is two wolves and a lamb voting on what to have for lunch. 
Liberty is a well-armed lamb contesting the vote."

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to