just a quick question regarding looping an array created by an array function:
i used to think this was really inefficient:
foreach(array_merge($list1,$list2,$list3) as $item) print $item;
or
foreach(array(1,2,3) as $item) print $item;
as opposed to:
$list = array_merge($list1,$list2,$list3);
foreach($list as $item) print $item;
or
$list = array(1,2,3);
foreach($list as $item) print $item;
-- i thought this because i was thinking array_merge() or array() or split() or any other function that returns an array was being called for each iteration of the loop, although now that i've thought about it that would be a horrible way to implement foreach, and i think the php developers are smarter than that.
i believe, in a foreach loop, a temporary hidden array is created before the first iteration. if that is the case, neither method would be significantly more effecient than the other.
thoughts?