3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $oldArray = array('a','b','c','d','e'); $newArray = array(); for($i = 0; $i < count($oldArray); $i+=2){ $key = $oldArray[$i]; $val = $oldArray[$i+1]; $newArray[$key] = $val; } var_dump($newArray);
Output for 5.3.28 - 5.3.29, 5.4.20 - 7.1.0
Notice: Undefined offset: 5 in /in/WMWZv on line 8 array(3) { ["a"]=> string(1) "b" ["c"]=> string(1) "d" ["e"]=> NULL }
Output for 5.3.0 - 5.3.27, 5.4.0 - 5.4.19
Notice: Undefined offset: 5 in /in/cFXFZ on line 8 array(3) { ["a"]=> string(1) "b" ["c"]=> string(1) "d" ["e"]=> NULL }
Output for 4.3.1 - 5.2.17
Notice: Undefined offset: 5 in /in/cFXFZ on line 8 array(3) { ["a"]=> string(1) "b" ["c"]=> string(1) "d" ["e"]=> NULL }
Output for 4.3.0
Notice: Undefined offset: 5 in /in/WMWZv on line 8 array(3) { ["a"]=> string(1) "b" ["c"]=> string(1) "d" ["e"]=> NULL }