my mind is going to explode. need to get the array element which has an id of 4 and 6 in array 1. basically its the difference of these two arrays. i tried using for each loop but i cant get the output that i want
Array 1(
0 => array(
id: 1
)
1 => array(
id: 4
)
2 => array(
id: 5
)
3 => array(
id: 6
)
)
Array 2(
0 => array(
id: 1
)
1 => array(
id: 5
)
)
the output i want:
new Array (
0 => array (
id: 4
)
1 => array (
id: 6)
)
what i've tried:
foreach ($array1 as $key => $value) {
foreach ($array2 as $key2 => $value2) {
if($value2['id'] !== $value['id']){
$result['id'] = $value2['id'];
}
}
}