3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $list = array(1, 2, 3); foreach ($list as &$item){ //var_dump($item); //var_dump($list); } foreach ($list as $item){ var_dump($item); var_dump($list); } print_r($list);
based on BM0CW
Output for 5.6.0 - 5.6.30, hhvm-3.15.4, 7.0.0 - 7.2.6
int(1) array(3) { [0]=> int(1) [1]=> int(2) [2]=> &int(1) } int(2) array(3) { [0]=> int(1) [1]=> int(2) [2]=> &int(2) } int(2) array(3) { [0]=> int(1) [1]=> int(2) [2]=> &int(2) } Array ( [0] => 1 [1] => 2 [2] => 2 )