I am trying to merge an item from one array and a full array from another I cant figure out what is the best solution?
Here is what I have:
$name = $item['name'];
// Returns = Admin
The $item['authority'] actually pulls back link this:
adverts,blog,comments
So I put them into there own array:
$auth = explode(",", $item['authority']);
// Returns
array(4) {
[0]=> string(7) "adverts"
[1]=> string(4) "blog"
[2]=> string(8) "comments"
[3]=>
}
I want to merge them into 1 array is this possible or what would be the best solution?
$joined = array_merge($name, $auth);
Just create a new array:
This will create a multidimensional array. You can’t use
array_merge()on$namesince it’s$nameisn’t an array. But, you could do: