You can use the PHP array_merge() function to merge the elements or values of two or more arrays together into a single array.

The merging is occurring in such a way that the values of one array are appended to the end of the previous array. Let's check out an example:

PHP Code:

<html>   <head>     <title>Code4Example</title>   </head>   <body>          <?php       $array1 = array(1, "fruit" => "banana", 2, "monkey", 3);       $array2 = array("a", "b", "fruit" => "apple", "city" => "paris", 4, "c");                echo "<pre>";       // Merging arrays together       $result = array_merge($array1, $array2);       print_r($result);      ?>    </body> </html>

Output:

Array (     [0] => 1     [fruit] => apple     [1] => 2     [2] => monkey     [3] => 3     [4] => a     [5] => b     [city] => paris     [6] => 4     [7] => c )