<?php
$array = [
[1, 30, 33,
['id' => 5]
];
$result = array_reduce($array, function (array $result, array $array) {
return array_merge($result, array_map(function ($id) { return compact('id'); }, $array);
}, []);
var_dump($result);
- Output for 5.4.0 - 5.4.29
- Parse error: syntax error, unexpected ';', expecting ']' in /in/75iLL on line 6
Process exited with code 255. - Output for 5.3.0 - 5.3.28
- Parse error: syntax error, unexpected '[' in /in/75iLL on line 3
Process exited with code 255.
preferences:
182.88 ms | 1395 KiB | 66 Q