Phpstrnatcmp () function usage Summary

Source: Internet
Author: User
This article mainly summarizes the usage of strnatcmp () function in php. If you need it, you can refer to it for help.

This article mainly summarizes the usage of strnatcmp () function in php. If you need it, you can refer to it for help.

Definition and Usage
Definition and usage
The strnatcmp () function compares two strings using a "natural" algorithm.
The strnatcmp () function is used to compare strings (case sensitive) with natural arithmetic operations ).

In a natural algorithm, the number 2 is less than the number 10. In computer sorting, 10 is less than 2, because the first number in "10" is less than 2.
In the "natural algorithm", 2 is smaller than 10. In the computer sequence, 10 is smaller than 2, because the first digit in "10" is "1" and it is smaller than 2.

This function returns:
This function returns the following values:

• 0-if the two strings are equal
0-if the string is equal
• <0-if string1 is less than string2
<0-If string1 is smaller than string2
•> 0-if string1 is greater than string2
> 0-If string1 is greater than string2
Syntax
Syntax

The Code is as follows:


Strnatcmp (string1, string2)

Parameter Description

String1Required. Specifies the first string to compare
Required parameter. Specifies the first string object involved in the comparison

String2Required. Specifies the second string to compare
Required parameter. Specifies the second string object for Parameter comparison

Tips and Notes
Notes
Note: The strnatcmp () is case-sensitive.
Note: The strnatcmp () function is case sensitive.

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

Example
Case

The Code is as follows:


"; Echo strnatcmp (" 10 Hello world! "," 2 Hello world! ");?>


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

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.