Having these two arrays with exactly the same number of items (3) and respectively correspondent data, how can I merge them to one unique array, combining the data like I show in array 3 example
// array 1
[ ▼ 3 items
{
"email": "john-doe@example.tld"
},
{
"email": "joe-bloggs@example.tld"
},
{
"email": "foo-bar@example.tld"
}
]
// array 2
[ ▼ 3 items
{
"name": "John Doe"
},
{
"name": "Joe Bloggs"
},
{
"name": "Foo Bar"
}
]
How can I merge them to be like this:
// array 3
[ ▼ 3 items
{
"name": "John Doe",
"email": "john-doe@example.tld"
},
{
"name": "Joe Bloggs",
"email": "joe-bloggs@example.tld"
},
{
"name": "Foo Bar",
"email": "foo-bar@example.tld"
}
]
I am using laravel php. I have tried array_merge($array1, $array2)
and some laravel's function $res = $array1->merge($array2);
but I can't get the result I want.