-2

No consider same keys, only join an array to another.

Array(0 => 'aaa', 1 => 'bbb');
Array(1 => 'ccc', 2 => 'ddd');

I hope the result:

Array(0 => 'aaa', 1 => 'bbb', 2 => 'ccc', 3 => 'ddd');

I do not want to write a function to join them. Is there any PHP function available for it?

Sougata Bose
  • 30,871
  • 8
  • 44
  • 87
Henry
  • 843
  • 1
  • 14
  • 28
  • 2
    Yes, there is a function for that. Did you try [looking in the PHP reference](http://php.net/array_merge)? – Marty Mar 08 '16 at 05:47

1 Answers1

1

You can use array_merge

<?php
   $array1 = Array(0 => 'aaa', 1 => 'bbb');
   $array2 = Array(1 => 'ccc', 2 => 'ddd');
   $result = array_merge($array1, $array2);
   print_r($result);
?>
Divyesh Savaliya
  • 2,602
  • 2
  • 16
  • 36