3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr1 = array(1, 2, 3, 4, 5); $arr2 = array('a', 'b', 'c', 'd'); $ref = &$arr1; foreach($ref AS $key=>$val) { echo "$key => $val \r\n"; if( $val === 2) { $ref = $arr2; } }
based on HeUXe
Output for 7.0.0 - 7.1.0
0 => 1 1 => 2 2 => 3 3 => 4 4 => 5
Output for 4.3.0 - 5.6.28
0 => 1 1 => 2 0 => a 1 => b 2 => c 3 => d