php strnatcmp()函數的用法總結_PHP教程

來源:互聯網
上載者:User
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 less than string2
<0 – 如果string1小於string2
•>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

http://www.bkjia.com/PHPjc/621719.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/621719.htmlTechArticleDefinition and Usage 定義和用法 The strnatcmp() function compares two strings using a "natural" algorithm. strnatcmp()函數的作用是:用自然運演算法則比較字串(...

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.