What do the 1, 0 and - 1 mean?
Posted: Thu Oct 27, 2011 5:23 am
Hi all,
Total noob here. I have been trawling through w3schools tutorials and finding most of it easy enough but I'm not sure what return values are doing in this function.
I was thinking true and false, but then the -1 totally threw me.
Thanks in advance!
Total noob here. I have been trawling through w3schools tutorials and finding most of it easy enough but I'm not sure what return values are doing in this function.
I was thinking true and false, but then the -1 totally threw me.
Thanks in advance!
Code: Select all
<?php
function myfunction($v1,$v2)
{
if ($v1===$v2)
{
return 0;
}
if ($v1>$v2)
{
return 1;
}
else
{
return -1;
}
}
$a1=array(0=>"Dog",1=>"Cat",2=>"Horse");
$a2=array(3=>"Dog",1=>"Cat",5=>"Horse");
print_r(array_diff_uassoc($a1,$a2,"myfunction"));
?>