in PHP, I have these two arrays, first one is "$ar1", the second is "$ar2":
Array
(
[0] => stdClass Object
(
[id] => 1505
[category] => blue
)
[1] => stdClass Object
(
[id] => 1805
[category] => red
)
)
Array
(
[1777] => stdClass Object
(
[id] => 1505
[category] => yellow
)
[1877] => stdClass Object
(
[id] => 1507
[category] => blue
)
)
I want to add $ar1 to $ar2 but only if the "id" is not already in $ar2. for example: the one with id "1505" should not be added to $ar2. here is the code I used:
$ar3 = array_merge_recursive($ar1, $ar2);