Zeev Suraski wrote: > A copy, yes.
Why? I thought the Zend Engine 2's new Object Model passed worked with references by default and only uses copies when "asked".
This has nothing to do with the new object model. That's why I used the word 'copy', which is generic to any PHP value, and not 'clone', which has object oriented associations... You could use foreach() in PHP 5 to change the objects themselves (you get that out of the box with the new object model), but you couldn't, for instance, replace the elements in the array with other objects or elements.
Look at the test attached below.
Zeev
<?php $arr = array(1 => "one", 2 => "two", 3 => "three");
foreach($arr as $key => $val) { $val = $key; }
print_r($arr);
foreach($arr as $key => &$val) { $val = $key; }
print_r($arr); ?>
---- Expected results:
Array ( [1] => one [2] => two [3] => three ) Array ( [1] => 1 [2] => 2 [3] => 3 )
-- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php