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);

preferences:
14.14 ms | 407 KiB | 5 Q