3v4l.org

run code in 300+ PHP versions simultaneously
<?php function partial(callable $callable, ...$initialargs): callable { return fn (...$args) => $callable(...$initialargs, ...$args); } $data = [ [ 'quiz' => 2, 'question' => 7, 'notif' => 'sup' ], [ 'quiz' => 3, 'question' => 7, 'notif' => 'pus' ], [ 'quiz' => 2, 'question' => 3, 'notif' => 'yoyoyo' ] ]; $keys = fn(array $data, string $key): callable => partial(array_keys(...), array_column($data, $key)); $indices = fn(array $data, string $key): array => array_map($keys($data, $key), array_column($data, $key, $key)); $map = fn(array $data): callable => partial(array_map(...), fn(int $i): array => $data[$i]); $byx = fn(array $data, string $x): array => array_map($map, $indices($data, $x)); $byquiz = $byx($data, 'quiz'); $byquizandquestion = array_map(fn($d) => $byx($d, 'question'), $byquiz); print_r($byquizandquestion);
Output for git.master_jit, git.master
Fatal error: Uncaught TypeError: {closure:/in/McAek:28}(): Argument #1 ($data) must be of type array, Closure given, called in /in/McAek on line 31 and defined in /in/McAek:28 Stack trace: #0 /in/McAek(31): {closure:/in/McAek:28}(Object(Closure), 'question') #1 [internal function]: {closure:/in/McAek:31}(Object(Closure)) #2 /in/McAek(31): array_map(Object(Closure), Array) #3 {main} thrown in /in/McAek on line 28
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:
41.86 ms | 405 KiB | 5 Q