3v4l.org

run code in 300+ PHP versions simultaneously
<?php function map(array $array, array $keys) { $filter = function ($branch) { return $branch; }; foreach ($keys as $key) { $filter = function ($branch) use ($filter, $key) { switch ($key) { case '*': case '?': return array_map(function () use ($dimension, $filter) { return $filter($dimension); }, $branch); default: return $filter($branch)[$key]; } }; } return $filter($array); } $array = [ 'a' => [ 'b' => [ [ 'c' => 'foo', ], [ 'c' => 'bar', ], [ 'c' => 'qux', ], ], ], ]; $keys = ['a', 'b', '*', 'c']; var_dump(map($array, $keys));
Output for git.master, git.master_jit
Warning: Undefined variable $dimension in /in/n7e9W on line 15 Warning: Trying to access array offset on value of type null in /in/n7e9W on line 19 Warning: Trying to access array offset on value of type null in /in/n7e9W on line 19 Warning: Undefined array key "c" in /in/n7e9W on line 19 NULL
Output for rfc.property-hooks
Warning: Undefined variable $dimension in /in/n7e9W on line 15 Warning: Trying to access array offset on null in /in/n7e9W on line 19 Warning: Trying to access array offset on null in /in/n7e9W on line 19 Warning: Undefined array key "c" in /in/n7e9W on line 19 NULL

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:
42.65 ms | 401 KiB | 8 Q