3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $ar = array('a' => 'b'); function cb($v) { return $v; } function keys($v, $k) { return $k; } print_r(array_map('cb', $ar)); print_r(array_map('cb', $ar, array_keys($ar))); $keys = array_map('keys', $ar); print_r(array_map('cb', $ar, $keys));
based on 25b74
Output for 7.1.0
Array ( [a] => b ) Array ( [0] => b ) Fatal error: Uncaught ArgumentCountError: Too few arguments to function keys(), 1 passed and exactly 2 expected in /in/6ljW4:5 Stack trace: #0 [internal function]: keys('b') #1 /in/6ljW4(9): array_map('keys', Array) #2 {main} thrown in /in/6ljW4 on line 5
Process exited with code 255.
Output for 5.1.0 - 7.0.14
Array ( [a] => b ) Array ( [0] => b ) Warning: Missing argument 2 for keys() in /in/6ljW4 on line 5 Notice: Undefined variable: k in /in/6ljW4 on line 5 Array ( [0] => b )
Output for 4.3.0 - 5.0.5
Array ( [a] => b ) Array ( [0] => b ) Warning: Missing argument 2 for keys() in /in/6ljW4 on line 5 Array ( [0] => b )