Phpstrnatcasecmp () compares two strings (case insensitive)

Source: Internet
Author: User
Tags first string
Phpstrnatcasecmp () uses a natural sorting algorithm to compare two strings (case insensitive). This article introduces the usage and examples of phpstrnatcasecmp () functions to coders, for more information, see. Definition and usage

The strnatcasecmp () function uses a "natural" algorithm to compare two strings.

In natural algorithms, number 2 is smaller than Number 10. In computer sorting, 10 is less than 2, because the first number in 10 is less than 2.

Note: strnatcasecmp () is case insensitive.

Syntax
strnatcasecmp(string1,string2)
Parameters Description
String1 Required. Specifies the first string to be compared.
String2 Required. Specifies the second string to be compared.

Return value
Return value:

This function returns:

  • 0-if the two strings are equal
  • <0-if string1 is smaller than string2
  • > 0-if string1 is greater than string2
PHP version: 4 +

Instance

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

Online operation

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.