Return-1 What does this mean? & Lt ;? Php & nbsp; functionmyfunction ($ v1, $ v2) {if ($ v1 $ v2) {return0; & nbsp;} if ($ v1 & gt; $ v2) {return1; & nbsp;} else {return-1; & nbsp ;}}$ a1array (0 & gt; & return-1 What does this mean?
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 "));
?>
The running result is as follows: Array ([0] => Dog [2] => Horse)
Returns 0, 1, and-1. I just don't understand this. I have always understood 0 and 1 as true and false. what about-1?
What is the function of return-1? Please take a look. thank you.
------ Solution --------------------
The returned value. In that function,-1 is another condition.
------ Solution --------------------
Input parameter $ v1, $ v2
1 indicates that $ v1 is greater than $ v2
-1 indicates that $ v1 is less than $ v2
0 indicates that $ v1 is equal to $ v2
------ Solution --------------------
Discussion
Input parameter $ v1, $ v2
1 indicates that $ v1 is greater than $ v2
-1 indicates that $ v1 is less than $ v2
0 indicates that $ v1 is equal to $ v2
------ Solution --------------------
User-defined function, compare index value... This is usually the case.
1, 0, and-1 indicate greater than, equal to, and less