Return-1 What does this mean? Solution-php Tutorial

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.