I need to get the difference between these two arrays, I\'ve tried array_diff($array1,$array2)
without success, any idea?
array1
Array
(
Maybe I'm misunderstanding, but can't you just do something like this for your specific problem?
$newStatuses = array();
foreach($array1 as $element1) {
foreach($array2 as $element2) {
if($element1['status'] == $element2['status']) {
continue 2;
}
}
$newStatuses[] = $element1;
}
Each element of $newStatuses will be an array with a 'status' element from array1 that was not in array2.
So, $newStatuses would be this:
Array
(
[0] => Array
(
[status] => 61192106047320064
)
)
have a look at this code, its part of cakephp but you may be able to adapt / rip it out
https://github.com/cakephp/cakephp/blob/master/cake/libs/set.php#L792
and the docs
http://book.cakephp.org/view/1496/diff
According to array_diff,
This function only checks one dimension of a n-dimensional array. Of course you can check deeper dimensions by using array_diff($array1[0], $array2[0]);.
Therefore you cannot diff the second dimension of these arrays directly.
Instead, maybe you can extract the status
values with array_map, save as two 1-dimensional arrays, and then array_diff
. If you have multiple keys, use a for loop.