I have two arrays that contain friend objects. I want to find the IDs that match each other to implement mutual friends functionality. If it's too complicated using PHP, maybe I'll do it in the mysql way.
These are example array items:
$array1 = array(1) {
["friends_list"]=>
array(3) {
[0]=>
object(stdClass)#29 (8) {
["notifica_ID"]=>
string(4) "2673"
}
[1]=>
object(stdClass)#30 (8) {
["notifica_ID"]=>
string(4) "3532"
}
[2]=>
object(stdClass)#31 (8) {
["notifica_ID"]=>
string(4) "3649"
}
}
}
$array2 = array(1) {
["friends_list"]=>
array(5) {
[0]=>
object(stdClass)#32 (8) {
["notifica_ID"]=>
string(4) "1679"
}
[1]=>
object(stdClass)#33 (8) {
["notifica_ID"]=>
string(4) "2137"
}
[2]=>
object(stdClass)#35 (8) {
["notifica_ID"]=>
string(4) "3186"
}
[3]=>
object(stdClass)#36 (8) {
["notifica_ID"]=>
string(4) "3187"
}
[4]=>
object(stdClass)#37 (8) {
["notifica_ID"]=>
string(4) "3649"
}
}
}
I want to the result to be:
$result = array(1) {
["friends_list"]=>
array(1) {
[0]=>
array(
["notifica_ID"]=>
string(4) "3649"
)
}
}
I have already tried array_intersect method but I don't know how can I implement it in array of objects.