Home > php教程 > php手册 > body text

php比较字符函数strnatcasecmp

WBOY
Release: 2016-06-13 11:16:54
Original
1601 people have browsed it

 

定义和用法
strnatcasecmp ( )函数比较两个字符串使用的是“自然”的算法。

在一个自然算法, 2号人数少于10 。在计算机排序, 10个小于2 ,因为在第一个数字“ 10 ”小于2 。

这个函数返回:

0 -如果这两个字符串相等
“ 0 -如果字符串小于字符串
“ 0 -如果字符串大于字符串
语法

strnatcasecmp(string1,string2)


参数说明string :必需的。指定的第一个字串比较string2:必需的。指定第二个字符串比较看看实例吧.

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

输出为1-1


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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!