I have two arrays like
Array
(
[0] => Array
(
[id] => 1
[controller] => users
[action] => index
)
[1] => Array
(
[id] => 1
[controller] => users
[action] =>
)
[2] => Array
(
[id] => 1
[controller] => users
[action] => login
)
)
Array
(
[0] => Array
(
[id] => 1
[controller] => users
[action] => index
)
[1] => Array
(
[id] => 1
[controller] => users
[action] =>
)
[2] => Array
(
[id] => 1
[controller] => users
[action] => logout
)
)
I want to remove complete nested array from 1st array if a match is found in 2nd array (Based on keys ['controller'] &&['action']). So in the first array only the 3rd [2] array is unique.
The output should be like :
Array
(
[0] => Array
(
[id] => 1
[controller] => users
[action] => login
)
)
Please Note Please note that the 2nd array doesn't necessary to be in same order as first. As opposed in my question where the first two arrays of each array are identical.
What i have tried is :
$result = array();
for($i=0; $i < count($a); $i++)
{
$result[] = array_diff($a[$i], $b[$i]);
}
print_r($result); // This doesn't give required output. It removes every thing and return like
Array
(
[0] => Array
(
)
[1] => Array
(
)
[2] => Array
(
[action] => login
)
)