On Tue, 2003-09-23 at 17:37, Eugene Lee wrote:
> On Tue, Sep 23, 2003 at 01:49:03PM -0700, Chris W. Parker wrote:
> : 
> : Robert Cummings <mailto:[EMAIL PROTECTED]> said:
> : >
> : > foreach( $data as $key => $value )
> : 
> : I don't use that syntax much so I'm not familiar with it. Maybe I should
> : start eh?
> 
> Another caveat: it works on a *copy* of the array.  This is fine for
> small arrays, but may be a performance killer for larger arrays.

I don't think you have enough knowledge of the PHP internals to make
that claim :) To qualify my statement, PHP doesn't not literally copy
data until you attempt to make a change. So in the above example $key
and $value are virtual copies of relevant data. If I were to try and
change either of these values then an explicit copy would be made at
that time, but not before. Thus since I actually make modifications on
the original $data array structure, my example makes no real copies
except when the new values is set in the original array. My example is
much more optimal than you think, mostly because of the oft unknown
optimizations made in the PHP engine itself.

Cheers,
Rob.
-- 
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com |
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting  |
| a powerful, scalable system for accessing system services  |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for       |
| creating re-usable components quickly and easily.          |
`------------------------------------------------------------'

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

Reply via email to