Home  >  Article  >  Backend Development  >  strnatcmp()函数,该如何处理

strnatcmp()函数,该如何处理

WBOY
WBOYOriginal
2016-06-13 12:17:46740browse

strnatcmp()函数
strnatcmp()函数是对字符串中的数字按照数字大小比较
$str1="mrsoft1";
$str2="MRSOFT2";
echo strnatcmp($str1,$str2);
预想结果是-1, 结果是1,请问这是什么原因
------解决思路----------------------

$str1 = "mrsoft1";<br />$str2 = "MRSOFT2";<br />echo strnatcmp($str1,$str2); //1 因为 m 大于 M<br /><br />$str1 = "mrsoft1";<br />$str2 = "mrsoft2";<br />echo strnatcmp($str1,$str2); //-1 这样才对<br /><br />$str1 = "mrsoft11";<br />$str2 = "mrsoft2";<br />echo strnatcmp($str1,$str2); //1 这才是本意 11 大于 2<br />

Statement:
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