3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $array = [2,3,4,5]; $index = "a"; $arrayB = array_map(function ($element) { $index++; return array($index => $element); }, $array); print_r($arrayB);
Output for 5.6.0 - 7.2.11
Notice: Undefined variable: index in /in/jU0Dh on line 7 Notice: Undefined variable: index in /in/jU0Dh on line 7 Notice: Undefined variable: index in /in/jU0Dh on line 7 Notice: Undefined variable: index in /in/jU0Dh on line 7 Array ( [0] => Array ( [1] => 2 ) [1] => Array ( [1] => 3 ) [2] => Array ( [1] => 4 ) [3] => Array ( [1] => 5 ) )