fork(1) download
  1. <?php
  2.  
  3. $old = array(5,5,4);
  4. $new = array(5,5,4,4);
  5.  
  6. function array_subtract($a, $b)
  7. {
  8. foreach ($b as $val) {
  9. $i = array_search($val, $a);
  10. if ($i !== false) {
  11. unset($a[$i]);
  12. }
  13. }
  14.  
  15. return array_values($a);
  16. }
  17.  
  18. $result = array_subtract($new, $old);
  19.  
  20. var_dump($result);
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
array(1) {
  [0]=>
  int(4)
}