I am trying to use array_diff
in order to see what changes had been made to an account. The account data is encoded as json files. The problem is that when I decode the json, I get a multidimensional array. As specified in the manual:
Note: Please note that 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]);
This comment seems to solve the problem- but what if I do not know how many dimensions are there, neither the depth of the arrays? To give a really simple example, I have those two files: abcd.json:
[{"name":"Tim Pearson","id":"17118"},{"name":"Ashley Danchen Chen","id":"504829084"},{"name":"Foisor Veronica","id":"100005485446135"}]
And blabla.json:
[{"name":"Tim Pearson","id":"17118"},{"name":"Foisor Veronica","id":"100005485446135"}]
And if I decode each of them, they will look like:
Array ( [0] => Array ( [name] => Tim Pearson [id] => 17118 ) [1] => Array ( [name] => Ashley Danchen Chen [id] => 504829084 ) [2] => Array ( [name] => Foisor Veronica [id] => 100005485446135 ) )
So what would I need is to make the difference, it would remain {"name":"Ashley Danchen Chen","id":"504829084"}
. But how to do that? array_diff
seems to be difficult to use now.