Answers for "how to collect array of objects in one value key in laravel"

0

how to collect array of objects in one value key in laravel

$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);
Posted by: Guest on May-03-2021

Code answers related to "how to collect array of objects in one value key in laravel"

Code answers related to "TypeScript"

Browse Popular Code Answers by Language