PHP Array Merge with preserve keys

Here are two arrays, use UNION array operator to merge $array1 and $array2 with preserve keys and no transformation of keys and values.

$array1 = array(
    1 => "News",
    14 => "Videos");

$array2 = array(
    422 => "Pranks",
    889 => "People",
    1978 => "Tweets");
Syntax
$result_array = ($array1 + $array2);
Output
Array
(
    [1] => News
    [14] => Videos
    [422] => Pranks
    [889] => People
    [1978] => Tweets
)
PHP Array Array Merge Posted on 2016-04-17 05:48:42