亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

PHP natsort() 函數(shù)

定義和用法

natsort() 函數(shù)用自然順序算法對給定數(shù)組中的元素排序。

natsort() 函數(shù)實(shí)現(xiàn)了“自然排序”,即數(shù)字從 1 到 9 的排序方法,字母從 a 到 z 的排序方法,短者優(yōu)先。數(shù)組的索引與單元值保持關(guān)聯(lián)。

如果成功,則該函數(shù)返回 TRUE,否則返回 FALSE。

語法

natsort(array)
參數(shù) 描述
array 必需。規(guī)定要進(jìn)行排序的數(shù)組。

例子

本函數(shù)所用的自然排序算法,與通常的計(jì)算機(jī)字符串排序算法(用于 sort())的區(qū)別,見下面示例:

<?php
$temp_files = array("temp15.txt","temp10.txt",
"temp1.txt","temp22.txt","temp2.txt");

sort($temp_files);
echo "Standard sorting: ";
print_r($temp_files);
echo "<br />";

natsort($temp_files);
echo "Natural order: ";
print_r($temp_files);
?>

輸出:

Standard sorting: Array
(
[0] => temp1.txt
[1] => temp10.txt
[2] => temp15.txt
[3] => temp2.txt
[4] => temp22.txt
)

Natural order: Array
(
[0] => temp1.txt
[3] => temp2.txt
[1] => temp10.txt
[2] => temp15.txt
[4] => temp22.txt
)