Examples of string comparison functions commonly used in PHP strcmp () are explained

Source: Internet
Author: User
Tags strcmp

int strcmp (String $str 1, String $str 2)

Compare in binary mode
Case-sensitive when compared to this function
The return value if STR1 is less than str2 returns <0 if STR1 is greater than str2 returns >0 if the two equals return 0.

<?PHP$STR1 = "Hello World";//$STR 1 equals the value of $str3 $str2 = "Hello World"; $str 3 = "Hello World";//$STR 1 is equal to the value of $STR3 echo strcmp ( $str 1, $str 2);//Output 1echo strcmp ($str 2, $str 1);//Output -1echo strcmp ($str 1, $str 3);//Output 0?>

There is also a function strcasecmp (), the usage is similar to the strcmp (), but is not case-insensitive, here no longer wordy

This article is from the "Golden Three" blog, please be sure to keep this source http://jinsanguo.blog.51cto.com/13363984/1970738

Examples of string comparison functions commonly used in PHP strcmp () are explained

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.