My problem is that I have two arrays that are not necessarily the same size that contain associative arrays which are always of the same size, for example:
$a = array([0] => array(["ref"]=> string(19) "ygz121byr46dl4795eu", ["place"]=> string(5) "Paris", ["date"]=> string(25) "2012-03-14T16:42:47+01:00", ...),
[1] => array(["ref"]=> string(19) "cer123bur45dl4795ef", ["place"]=> string(8) "New-York", ["date"]=> string(25) "2015-06-14T05:05:49+01:00", ...),
[2] => array(["ref"]=> string(19) "abc123abc12ab1234ab", ["place"]=> string(6) "London", ["date"]=> string(25) "2020-02-12T08:03:39+01:00", ...),
...);
$b = array([0] => array(["ref"]=> string(19) "ygz121byr46dl4795eu", ["place"]=> string(5) "Paris", ["date"]=> string(25) "2012-03-14T16:42:47+01:00", ...),
[1] => array(["ref"]=> string(19) "cer123bur45dl4795ef", ["place"]=> string(8) "New-York", ["date"]=> string(25) "2015-06-14T05:05:49+01:00", ...),
...);
I tried several methods but nothing seems to work, or I only get the keys without the values. I want to get the difference (all elements in $a not present $b) in an array, so here the result would be :
$result = array( array(["ref"]=> string(19) "abc123abc12ab1234ab", ["place"]=> string(6) "London", ["date"]=> string(25) "2020-02-12T08:03:39+01:00", ...),
...);
The "ref" key is a unique field for each array, so I needed in $result all the documents whose "ref" key is not in $b
EDIT : I found (https://stackoverflow.com/a/42530586/15742179) a way to do it by using array_diff(), array_map(), json_encode() and decode() method. Thanks to Ifnot
// compare all value
$result = array_diff(array_map('json_encode', $a), array_map('json_encode', $b));
// decode the result
$result = array_map('json_decode', $result);