3v4l.org

run code in 300+ PHP versions simultaneously
<?php $ar = ['a','b','c']; $arr =& $ar; // both are now references foreach ($arr as $dummy) { $arr []= 'foo'; } var_dump($arr);
Output for 7.3.0 - 7.3.33, 7.4.0 - 7.4.30, 8.0.0 - 8.0.23, 8.1.0 - 8.1.10
array(6) { [0]=> string(1) "a" [1]=> string(1) "b" [2]=> string(1) "c" [3]=> string(3) "foo" [4]=> string(3) "foo" [5]=> string(3) "foo" }

preferences:
58.41 ms | 409 KiB | 5 Q