Hey, we can merge two array without changing it’s index key is simply adding it. See the below example.
suppose we have two array $a and $b, the just add it by +sing, Like $a+$b, then out put will be an array without changing its index key.
1 2 3 4 5 | <?php $a=array(1=>"red",2=>"green"); $b=array(3=>"blue",4=>"black"); print_r($a+$b); ?> |
Output-:
1 | Array ( [1] => red [2] => green [3] => blue [4] => black ) |