I'm building application that tells user which are old and which are new bank notes when I increase sum with X. Everything is fine, but I'm wondering how I can now get list of added and removed items of array?
$old = array(1,5,10);
$new = array(1,5,1);
$added = array_diff($new,$old);
$removed = array_diff($old,$new);
And this is what code above returns:
-
$added
isarray()
. Incorrect, it should bearray([2] => 1)
. -
$removed
isarray([2] => 10)
. Correct.
What am I doing wrong, and how can I fix it?