- var_dump: documentation ( source)
<?php
$a = ['a' => 'a', 'b' => 'b'];
foreach ($a as &$value) {
$value = 'C';
}
$value = 'D'; //$value is still bound by-reference
echo 'Unintended Results: ' . PHP_EOL;
var_dump($a);
echo PHP_EOL;
$a = ['a' => 'a', 'b' => 'b'];
foreach ($a as &$value) {
$value = 'C';
}
unset($value);
$value = 'D';
echo 'Expected Results: ' . PHP_EOL;
var_dump($a);