📜  如何在 laravel 的一个值键中收集对象数组 - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:32.811000             🧑  作者: Mango

代码示例1
$arr = json_decode($str, true);
$names = array_column($arr, "name");
$codes = array_column($arr, "code");

foreach(array_unique($names) as $name){
    $new[$name] = array_intersect_key($codes, array_intersect($names, [$name]));
}
var_dump($new);