3v4l.org

run code in 300+ PHP versions simultaneously
<?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 git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "percy" in /in/Tvodf on line 11 Fatal error: Uncaught TypeError: array_intersect_key(): Argument #1 ($array) must be of type array, null given in /in/Tvodf:11 Stack trace: #0 /in/Tvodf(11): array_intersect_key(NULL, Array) #1 /in/Tvodf(10): coolPluck(Array, Array) #2 /in/Tvodf(22): coolPluck(Array, Array) #3 {main} thrown in /in/Tvodf on line 11
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
67.74 ms | 401 KiB | 8 Q