Can someone clarify a few things. ? Does unset($val) go after this line ?
foreach ($arr1 as $key => &$val) {}
Why is the output or $arr1
taking the value of 6 for key c ?
I have tried using unset( )
and destroy_arr1( )
but neither resolve this.
Maybe I did not use the above functions in the proper location.
$arr1 = array("a" => 1, "b" => 2, "c" => 3);
$arr2 = array("x" => 4, "y" => 5, "z" => 6);
foreach ($arr1 as $key => &$val) {}
foreach ($arr2 as $key => $val) {}
var_dump($arr1);
var_dump($arr2);
?>
The output is:
array(3) { ["a"]=> int(1) ["b"]=> int(2) ["c"]=> &int(6) }
array(3) { ["x"]=> int(4) ["y"]=> int(5) ["z"]=> int(6) }