Let\'s say I have following arrays:
Array
(
[0] => Array
(
[id] => 5
[name] => Education
As long as both arrays always have every id in them, what about sorting the two arrays by that 'id' field, then letting php do the merge?
function cmp($a, $b) {
return ((int) $a['id'] < (int) $b['id']) ? -1 : 1;
}
usort($array1, 'cmp');
usort($array2, 'cmp');
$result = array_merge($array1, $array2);
Have not tested the code, but it demonstrates the idea.