Jump to content

array_diff_uassoc help


sasori

Recommended Posts

hi, I was reviewing functions in php, and then i bumped into this array_diff_uassoc function, it doesn't give much example on the online manual. I was trying to compare the first array to 2 different arrays. on the manual it says this function can accept 1 or more arrays to compare against but then I am receiving this error

Warning:  Missing argument 3 for key_compare_func() in C:\xampp\htdocs\practice\test2\test2.php on line 7

 

and here's my code

 

$a = array("a"=>"apple","b"=>"banana","d"=>"carrot","f"=>"fuck");
$b = array("a"=>"apple","b"=>"banana","c"=>"carrot","f"=>"fuck");
$c = array("a"=>"apple","b"=>"banana","e"=>"carrot","fuck");

function key_compare_func($a,$b,$c){
    if($a === $b){
      return 0;
    }
    if($a === $c){
      return 0;
    }
    if(($a > $b) && ($a > $c)){
      return 1;
    }else{
      return -1;
    }
}
echo "<pre>",print_r(array_diff_uassoc($a,$b,$c,"key_compare_func")),"</pre>";

 

please help me out.TIA.

Link to comment
https://forums.phpfreaks.com/topic/164599-array_diff_uassoc-help/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.