fork download
  1. <?php
  2. $a1 = array(
  3. ['111', '111', '111'],
  4. ['222', '222'],
  5. ['333', '333', '333'],
  6. );
  7.  
  8. $a2 = array(
  9. ['111', '111', '111'],
  10. ['333', '333', '333'],
  11. ['444', '444', '444'],
  12. );
  13.  
  14. $new_a1 = array();
  15. $new_a2 = array();
  16.  
  17. foreach ($a1 as $value)
  18. $new_a1[json_encode($value)]=$value;
  19.  
  20. foreach ($a2 as $value)
  21. $new_a2[json_encode($value)]=$value;
  22.  
  23. $added = array_diff_assoc($new_a2,$new_a1);// Добавлено
  24. $removed = array_diff_assoc($new_a1,$new_a2);// Удалено
  25.  
  26. echo "------ADDED-----\n";
  27. var_dump($added);
  28. echo "------REMOVED-----\n";
  29. var_dump($removed);
Success #stdin #stdout #stderr 0.02s 24460KB
stdin
Standard input is empty
stdout
------ADDED-----
array(1) {
  ["["444","444","444"]"]=>
  array(3) {
    [0]=>
    string(3) "444"
    [1]=>
    string(3) "444"
    [2]=>
    string(3) "444"
  }
}
------REMOVED-----
array(1) {
  ["["222","222"]"]=>
  array(2) {
    [0]=>
    string(3) "222"
    [1]=>
    string(3) "222"
  }
}
stderr
PHP Notice:  Array to string conversion in /home/9hpe3C/prog.php on line 23
PHP Notice:  Array to string conversion in /home/9hpe3C/prog.php on line 23
PHP Notice:  Array to string conversion in /home/9hpe3C/prog.php on line 23
PHP Notice:  Array to string conversion in /home/9hpe3C/prog.php on line 23
PHP Notice:  Array to string conversion in /home/9hpe3C/prog.php on line 24
PHP Notice:  Array to string conversion in /home/9hpe3C/prog.php on line 24
PHP Notice:  Array to string conversion in /home/9hpe3C/prog.php on line 24
PHP Notice:  Array to string conversion in /home/9hpe3C/prog.php on line 24