I have two associative array which have many content same and so I want to combine those two arrays in such a way that if I have `a` in array 1 and `a` in array 2 than in array 3 I should have entries for both `a's` and not 1.

I have tried using array\_merge but it would overwrite entries in 1st array if there are any duplicates in 2nd array, I have also tried using `+` but it gives me fatal error saying `Fatal error: Unsupported operand types in /home/code.php` then I tried doing

`(array)$ar3 = (array)$ar1 +(array)$ar2` and it seems to add up. I want to know is this the correct way to do it and also why did initially I got fatal error and than it worked as I had already defined $ar3, $ar2, $ar1 as array types. 

```
$orders = new Order(); 
$prospectOffers = $orders->getOrder($orderConfNumber); 
$prospectOffersResult = json_decode($prospectOffers,true); 
$shoppingBasket = $cart->getCartItems(); 
var_dump($prospectOffersResult); // Both are arrays 
var_dump($shoppingBasket); //Both are arrays 
(array)$result = (array)$prospectOffersResult+(array)$shoppingBasket;

```

Thanks.