First of all to explain what I am trying to do: I make array as a family tree of somebody. I take two persons, make their family trees from information in my mysql database, and then I want to check if they have any family connections. Like lets say personA
's grandfather could be personB
's great-grandfather. It is very important to know if the family connection exists in which level it exists. I mean I must to know if for example personA
's grandfather is personB
's great-grandfather. It would mean that the connection is between array a
level 2 array and array b
level 3 array. I must to know these numbers 2 and 3 in this situation.
So I have two multidimensional arrays with name a
and b
. I need to find out if there is any multiple values between array a
and b
and if there are some multiple values I must to find out where are they located in array a
and array b
.
My arrays looks like that:
[0]=> array(4) {
["id"]=> "1"
["father"]=> [0]=> array(4) {
["id"]=> "11"
["father"]=> [0]=> array(4) {
["id"]=> "111"
["father"]=> ""
["mother"]=> ""
}
["mother"]=> [0]=> array(4) {
["id"]=> "112"
["father"]=> ""
["mother"]=> ""
}
}
["mother"]=> [0]=> array(4) {
["id"]=> "12"
["father"]=> [0]=> array(4) {
["id"]=> "121"
["father"]=> ""
["mother"]=> ""
}
["mother"]=> [0]=> array(4) {
["id"]=> "122"
["father"]=> ""
["mother"]=> ""
}
}
}
So if I have 2 arrays like the one I showed you above, how can I check if there is any same values in arrays 'a' and 'b'?