Compare the values of three arrays (use a user-defined function to compare the values), and return the differences:


SUBMITTED BY: henry1874w

DATE: June 26, 2017, 4:47 p.m.

FORMAT: Text only

SIZE: 343 Bytes

HITS: 314

  1. <?php
  2. function myfunction($a,$b)
  3. {
  4. if ($a===$b)
  5. {
  6. return 0;
  7. }
  8. return ($a>$b)?1:-1;
  9. }
  10. $a1=array("a"=>"red","b"=>"green","c"=>"blue","yellow");
  11. $a2=array("A"=>"red","b"=>"GREEN","yellow","black");
  12. $a3=array("a"=>"green","b"=>"red","yellow","black");
  13. $result=array_udiff($a1,$a2,$a3,"myfunction");
  14. print_r($result);
  15. ?>

comments powered by Disqus