php strnatcmp()函數(shù)的用法總結
Definition and Usage
定義和用法
The strnatcmp() function compares two strings using a "natural" algorithm.
strnatcmp()函數(shù)的作用是:用自然運算法則比較字符串(大小寫敏感)。
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”中的第一個數(shù)字是“1”,它小于2。
This function returns:
這個函數(shù)將返回下列值:
•0 - if the two strings are equal
0 – 如果字符串相等
•<0 - if string1 is less than string2
<0 – 如果string1小于string2
•>0 - if string1 is greater than string2
>0 – 如果string1大于string2
Syntax
語法
strnatcmp(string1,string2)
Parameter參數(shù) | Description描述 |
---|---|
string1 | Required. Specifies the first string to compare 必要參數(shù)。指定參與比較的第一個字符串對象 |
string2 | Required. Specifies the second string to compare 必要參數(shù)。指定參數(shù)比較的第二個字符串對象 |
Tips and Notes
注意點
Note: The strnatcmp() is case-sensitive.
注意:strnatcmp()函數(shù)是區(qū)分大小寫的。
--------------------------------------------------------------------------------
Example
案例
<?phpecho strnatcmp("2Hello world!","10Hello world!");echo "<br />";echo strnatcmp("10Hello world!","2Hello world!");?>
The output of the code above will be:
上述代碼將輸出下面的結果:-1 1
相關文章
php 調試利器debug_print_backtrace()
debug_print_backtrace() 是一個很低調的函數(shù),很少有人注意過它. 不過當我對著一個對象調用另一個對象再調用其它的對象和文件中的一個函數(shù)出錯時,它正在一邊笑呢2012-07-07KindEditor在php環(huán)境下上傳圖片功能集成的方法示例
這篇文章主要介紹了PHP環(huán)境下如何實現(xiàn)使用KindEditor編輯器上傳圖片,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友們下面隨著小編來一起學習學習吧2020-07-07PHP實現(xiàn)導出excel數(shù)據(jù)的類庫用法示例
這篇文章主要介紹了PHP實現(xiàn)導出excel數(shù)據(jù)的類庫用法,結合實例形式分析了php操作Excel數(shù)據(jù)的讀取與導出操作相關實現(xiàn)技巧,需要的朋友可以參考下2016-10-10php版本CKEditor 4和CKFinder安裝及配置方法圖文教程
這篇文章主要介紹了php版本CKEditor 4和CKFinder安裝及配置方法,結合圖文與實例形式詳細分析了php安裝及配置CKEditor 4和CKFinder相關實現(xiàn)步驟、操作技巧與注意事項,需要的朋友可以參考下2019-06-06