Home > Backend Development > PHP Tutorial > PHP comparison character function strnatcasecmp_PHP tutorial

PHP comparison character function strnatcasecmp_PHP tutorial

WBOY
Release: 2016-07-20 11:00:19
Original
985 people have browsed it

Definition and usage
The strnatcasecmp() function compares two strings using a "natural" algorithm.

In a natural algorithm, the number of people on No. 2 is less than 10. In computer sorting, 10 is less than 2 because the first number "10" is less than 2.

This function returns:

0 - if the two strings are equal
"0 - if string is less than string
"0 - if string is greater than string
Grammar

strnatcasecmp(string1,string2)


Parameter description string: required. The first string specified is compared string2: required. Specify the second string comparison and see the example.

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

The output is 1-1


www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/445522.htmlTechArticleDefinition and Usage The strnatcasecmp() function compares two strings using a natural algorithm. In a natural algorithm, number 2 is less than 10 people. In computer sorting, 10 are less than 2...
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template