Reputation: 35
I have two array from two query. I want to join two array into one array. Example:
Array1
[
{
fakultas: "Ekonomi dan Bisnis"
},
{
fakultas: "Hukum"
}
]
Array2
[
{
jumlah_wisudawan: "55"
},
{
jumlah_wisudawan: "17"
}
]
How to join two array above into one array like this:
[
{
fakultas: "Ekonomi dan Bisnis",
jumlah_wisudawan: "55"
},
{
fakultas: "Hukum",
jumlah_wisudawan: "17"
}
]
Please help me, thanks before.
Upvotes: 0
Views: 2860
Reputation: 1638
You should use array_merge
not array_combine
array_merge($array1, $array2);
See documentation of PHP array_combine vs. array_merge
Upvotes: 1
Reputation: 1152
You could use collections:
https://laravel.com/docs/5.4/collections
$collection = collect($array1, $array2);
and if you want to get that array, you can do it like this:
$collection->all();
Upvotes: 1