fork download
  1. <?php
  2.  
  3. $ar1 = [
  4. 0 => '1-0',
  5. 'a' => '1-a',
  6. 'b' => '1-b'
  7. ];
  8.  
  9.  
  10. $ar2 = [
  11. 0 => '2-0',
  12. 1 => '2-1',
  13. 'b' => '2-b',
  14. 'c' => '2-c'
  15. ];
  16.  
  17. print_r(array_merge($ar1,$ar2));
  18. print_r($ar1+$ar2);
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
Array
(
    [0] => 1-0
    [a] => 1-a
    [b] => 2-b
    [1] => 2-0
    [2] => 2-1
    [c] => 2-c
)
Array
(
    [0] => 1-0
    [a] => 1-a
    [b] => 1-b
    [1] => 2-1
    [c] => 2-c
)