I have two arrays like this:
array(
\'11\' => \'11\',
\'22\' => \'22\',
\'33\' => \'33\',
\'44\' => \'44\'
);
array(
\'44\' => \'44\',
\'55
To do this, you can loop through one and append to the other:
'11',
'22' => '22',
'33' => '33',
'44' => '44'
);
$test2 = array(
'44' => '44',
'55' => '55',
'66' => '66',
'77' => '77'
);
function combineWithKeys($array1, $array2)
{
foreach($array1 as $key=>$value) $array2[$key] = $value;
asort($array2);
return $array2;
}
print_r(combineWithKeys($test1, $test2));
?>
UPDATE: KingCrunch came up with the best solution: print_r($array1+$array2);