I want to merge the arrays inside the array so that i can get a single array having all data in laravel
[
[
{
"view_id": 1,
"meta_detail_id": 1
},
{
"view_id": 2,
"meta_detail_id": 1
}
],
[
{
"view_id": 7,
"meta_detail_id": 4
}
]
]
this is $data
array having two array inside it and expected result is
[
{
"view_id": 1,
"meta_detail_id": 1
},
{
"view_id": 2,
"meta_detail_id": 1
},
{
"view_id": 7,
"meta_detail_id": 4
}
]
I have tried with array_merge but got same result
$merged = call_user_func_array('array_merge', array($data));
$merged=array_merge(...array($data));
return $merged;
CodePudding user response:
laravel collection example.
collect($array)->flatten(1);