3v4l.org

run code in 300+ PHP versions simultaneously
<?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);

preferences:
23.99 ms | 404 KiB | 5 Q