3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function coolPluck($array, $allowed) { $output = array(); foreach($array as $k => $v) { if(is_array($v)) { $results = coolPluck($v, $allowed); $output[] = array_intersect_key($results[$k], array_flip($allowed)); } } return $output; } $testArray = array('test' => array('percy' => array('percy' => 'hatcherson'), 'percy' => array('mitchell', 'anderson'))); var_dump(coolPluck($testArray, array('percy')));
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
Notice: Undefined index: percy in /in/Tvodf on line 11 Warning: array_intersect_key(): Argument #1 is not an array in /in/Tvodf on line 11 Notice: Undefined index: test in /in/Tvodf on line 11 Warning: array_intersect_key(): Argument #1 is not an array in /in/Tvodf on line 11 array(1) { [0]=> NULL }
Output for hhvm-3.10.0 - 3.12.0
Notice: Undefined index: percy in /in/Tvodf on line 11 Warning: array_intersect_key() expects parameter 1 to be an array or collection in /in/Tvodf on line 11 Notice: Undefined index: test in /in/Tvodf on line 11 Warning: array_intersect_key() expects parameter 1 to be an array or collection in /in/Tvodf on line 11 array(1) { [0]=> NULL }
Output for 5.1.0 - 5.2.17
Notice: Undefined index: percy in /in/Tvodf on line 11 Warning: array_intersect_key(): Argument #1 is not an array in /in/Tvodf on line 11 Notice: Undefined index: test in /in/Tvodf on line 11 Warning: array_intersect_key(): Argument #1 is not an array in /in/Tvodf on line 11 array(1) { [0]=> NULL }
Output for 5.0.0 - 5.0.5
Fatal error: Call to undefined function array_intersect_key() in /in/Tvodf on line 11
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: array_intersect_key() in /in/Tvodf on line 11
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: array_intersect_key() in /in/Tvodf on line 11
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: array_intersect_key() in /in/Tvodf on line 11