Code Comments
Programming Forum and web based access to our favorite programming groups.> > correct. but i think there is a caveat in php4 with foreach. the > > This is correct. See > http://www.php.net/manual/en/contro...res.foreach.php for details. This makes me even less sure I really know what is going on! According to the foreach docs, foreach works on a copy, therefore it should make no difference whether or not the array is passed to Smarty as a copy or by reference, because either way the foreach will create a "new" copy which it will change. However, in addition foreach also updates the internal array-pointer, as Messju points out, so *if* this is considered a change of the array then we'll now have three copies of essentially the same array. However (again), my (hazy) recollection is that the array copy will itself just be a new set of array indexes pointing to references the original data, unless/until that data changes. So the overall memory usage of this whole process, assuming a large array, should be little over that used for the array itself. This should be semi-trivial to test - create a large array, look at the memory used, then perform the copy/foreach steps and see how it changes. If I get chance I might play with this some more, but right now I shouldn't even really be writing this, I have too much else I should be doing. -- Mark Rogers, More Solutions Ltd
Post Follow-up to this message
Show a Printable Version
Email This Page to Someone!
Receive updates to this thread
Powered by vBulletin
Copyright 2000-2006 Jelsoft Enterprises Limited.