I have two arrays, $nodes and $result. I want to create a third array, showing the differences. This might have been easy using something like array_diff() however, my two arrays are in a different format and here is where I am getting into trouble:
$nodes array is the result of a raw SQL query and looks like this ( abbreviated):
array (size=12)
0 =>
object(stdClass)[434]
public 'name' => string 'Architectural' (length=13)
public 'depth' => int 4
1 =>
object(stdClass)[435]
public 'name' => string 'Asphalt' (length=7)
public 'depth' => int 3
2 =>
object(stdClass)[436]
public 'name' => string 'Cedar' (length=5)
public 'depth' => int 3
$resultarray is the outcome of filtering the $nodes array with a for loop to find those nodes with a certain depth. It looks like this:
array (size=3)
0 => string 'Materials' (length=9)
1 => string 'Root' (length=4)
2 => string 'Services' (length=8)
I want to compare the two arrays, and find those values which do not appear in the $result array.
I have tried to get them into the same format with $nodes->toArray() but that doesn't work.
Any ideas how I might how I can find the differences in two arrays?
Many thanks !