最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

PHP natsort() 函數(shù)

定義和用法

natsort() 函數(shù)用自然順序算法對(duì)給定數(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
)
扎囊县| 乌恰县| 望奎县| 沛县| 泉州市| 石泉县| 邹平县| 赫章县| 连平县| 呼图壁县| 慈溪市| 青神县| 新绛县| 乾安县| 抚松县| 和田县| 桃江县| 富宁县| 姜堰市| 浙江省| 舞钢市| 普定县| 犍为县| 五常市| 日土县| 襄樊市| 长沙县| 都兰县| 建德市| 平舆县| 揭阳市| 淳安县| 云安县| 县级市| 永定县| 大余县| 绥德县| 黄山市| 定南县| 株洲县| 镇坪县|