See this
If you want to append array elements from the second array to the first array while not overwriting the elements from the first array and not re-indexing, use the + array union operator:
<?php
$array1 = array(0 => 'zero_a', 2 => 'two_a', 3 => 'three_a');
$array2 = array(1 => 'one_b', 3 => 'three_b', 4 => 'four_b');
$result = $array1 + $array2;
var_dump($result);
?>
The keys from the first array will be preserved. If an array key exists in both arrays, then the element from the first array will be used and the matching key's element from the second array will be ignored.
array(5) {
[0]=>
string(6) "zero_a"
[2]=>
string(5) "two_a"
[3]=>
string(7) "three_a"
[1]=>
string(5) "one_b"
[4]=>
string(6) "four_b"
}
Your solution should be:
<?
$arr1 = array (
30=> 30,
28=> 28,
27=> 27,
16=> 16
);
$arr2 = array (
27 => array (
person_id => 27,
person_name => "Jazz Club",
person_job => 10,
drink_price => 5
)
);
$newarr = $arr2 + $arr1;
print_r($newarr);
?>
Gives the following result
Array
(
[27] => Array
(
[person_id] => 27
[person_name] => Jazz Club
[person_job] => 10
[drink_price] => 5
)
[30] => 30
[28] => 28
[16] => 16
)
[27] => [27] => Array ( [person_id] => 27...or this[27] => Array ( [person_id] => 27...please check your question.