PHP strnatcmp () Function Usage Summary _php tutorial

Source: Internet
Author: User
Definition and Usage
Definition and usage
The strnatcmp () function compares the strings using a "natural" algorithm.
The strnatcmp () function works by comparing strings (case sensitive) with natural algorithms.

In a natural algorithm, the number 2 was less than the number 10. In computer sorting, than 2, because the first number in "Ten" is less than 2.
In the "Natural algorithms", 2:10 is small. In the computer sequence, 10:2 is small, because the first number in "10" is "1", which is less than 2.

This function returns:
This function will return the following values:

0-if the strings is equal
0– if the strings are equal
<0-if string1 is less than string2
<0– if string1 is less than string2
>0-if string1 is greater than string2
>0– if string1 is greater than string2
Syntax
Grammar

Copy CodeThe code is as follows:
STRNATCMP (STRING1,STRING2)
parameter Parameters Description Description
String1 Required. Specifies the first string to compare
Necessary parameters. Specifies the first string object to participate in the comparison
string2 Required. Specifies the second string to compare
Necessary parameters. A second string object that specifies a parameter comparison

Tips and Notes
Watch out.
Note:the strnatcmp () is case-sensitive.
Note: the STRNATCMP () function is case-sensitive.

--------------------------------------------------------------------------------

Example
Case
Copy the Code code as follows:
"; Echo strnatcmp (" 10Hello world! "," 2Hello world! "); >

The output of the code above would be:
The above code will output the following result:-1 1

http://www.bkjia.com/PHPjc/621719.html www.bkjia.com true http://www.bkjia.com/PHPjc/621719.html techarticle definition and usage definitions and usages the strnatcmp () function compares the strings using a "natural" algorithm. STRNATCMP () function is: Compare strings (...) with natural algorithms .

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