how to change the $arr
array into the structure of $newArr
$arr = [
[
"id" => "1",
"name" => "a",
"attr" => "",
"val" => "10"
],
[
"id" => "1",
"name" => "a",
"attr" => "",
"val" => "11"
],
[
"id" => "2",
"name" => "b",
"attr" => "",
"val" => "12"
],
[
"id" => "2",
"name" => "b",
"attr" => "",
"val" => "13"
],
];
Array structure to be changed:
$arr = [
[
"id" => "1",
"name" => "a",
"info" => [
["attr" => "", "val" => "10"]
["attr" => "", "val" => "11"]
]
],
[
"id" => "2",
"name" => "b",
"info" => [
["attr" => "", "val" => "12"]
["attr" => "", "val" => "13"]
]
]
];