contate two arrays php code example
Example 1: php array merge for associative arrays
<?php
$array1 = array('key1' => 'test1', 'key2' => 'test2');
$array2 = array('key3' => 'test3', 'key4' => 'test4');
$resultArray = array_merge($array1, $array2);
$resultArray = $array1 + $array2;
Example 2: php join array
Definition and Usage
The join() function returns a string from the elements of an array.
The join() function is an alias of the implode() function.
Note: The join() function accept its parameters in either order. However, for consistency with explode(), you should use the documented order of arguments.
Note: The separator parameter of join() is optional. However, it is recommended to always use two parameters for backwards compatibility.
Syntax
join(separator,array)
Example
Join array elements with a string:
<?php
$arr = array('Hello','World!','Beautiful','Day!');
echo join(" ",$arr);
?>
Output:
Hello World! Beautiful Day!