-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
  • 31,517
  • 8
  • 49
  • 87
Henry
  • 1,077
  • 1
  • 16
  • 41
  • 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,692
  • 2
  • 18
  • 37