登录  /  注册

php strnatcmp()函数的用法总结_PHP教程

php中文网
发布: 2016-07-13 17:17:51
原创
816人浏览过

Definition and Usage
定义和用法
The strnatcmp() function compares two strings using a "natural" algorithm.
strnatcmp()函数的作用是:用自然运算法则比较字符串(大小写敏感)。

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.
在“自然运算法则”中,2比10小。在计算机序列当中,10比2小,因为“10”中的第一个数字是“1”,它小于2。

This function returns:
这个函数将返回下列值:

•0 - if the two strings are equal
0 – 如果字符串相等
••>0 - if string1 is greater than string2
>0 – 如果string1大于string2
Syntax
语法

复制代码 代码如下:

strnatcmp(string1,string2)
Parameter参数 Description描述
string1 Required. Specifies the first string to compare
必要参数。指定参与比较的第一个字符串对象
string2 Required. Specifies the second string to compare
必要参数。指定参数比较的第二个字符串对象

Tips and Notes
注意点
Note: The strnatcmp() is case-sensitive.
注意:strnatcmp()函数是区分大小写的。

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

Example
案例

复制代码 代码如下:

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

The output of the code above will be:
上述代码将输出下面的结果:-1 1

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/621719.htmlTechArticleDefinition and Usage 定义和用法 The strnatcmp() function compares two strings using a "natural" algorithm. strnatcmp()函数的作用是:用自然运算法则比较字符串(...
智能AI问答
PHP中文网智能助手能迅速回答你的编程问题,提供实时的代码和解决方案,帮助你解决各种难题。不仅如此,它还能提供编程资源和学习指导,帮助你快速提升编程技能。无论你是初学者还是专业人士,AI智能助手都能成为你的可靠助手,助力你在编程领域取得更大的成就。
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
关于CSS思维导图的课件在哪? 课件
凡人来自于2024-04-16 10:10:18
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2024 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号