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


SUBMITTED BY: henry1874w

DATE: June 23, 2017, 9:23 p.m.

FORMAT: Text only

SIZE: 333 Bytes

HITS: 230

  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");
  11. $a2=array("a"=>"black","b"=>"yellow","d"=>"brown");
  12. $a3=array("e"=>"purple","f"=>"white","a"=>"gold");
  13. $result=array_diff_ukey($a1,$a2,$a3,"myfunction");
  14. print_r($result);
  15. ?>

comments powered by Disqus