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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.