PHP natcasesort() 函数
PHP 教程
· 2019-01-22 20:43:55
定义和用法
natcasesort() 函数用"自然排序"算法对数组进行排序。键值保留它们原始的键名。
在自然排序算法中,数字 2 小于 数字 10。在计算机排序算法中,10 小于 2,因为 "10" 中的第一个数字小于 2。
该函数不区分大小写。
如果成功,该函数返回 TRUE,如果失败则返回 FALSE。
语法
natcasesort(array)
| 参数 | 描述 |
|---|---|
| array | 必需。规定要进行排序的数组。 |
实例
<?php
$temp_files = array("temp15.txt","Temp10.txt",
"temp1.txt","Temp22.txt","temp2.txt");
natsort($temp_files);
echo "Natural order: ";
print_r($temp_files);
echo "<br />";
natcasesort($temp_files);
echo "Natural order case insensitve: ";
print_r($temp_files);
?>
上面代码将输出:
Natural order: Array ( [0] => Temp10.txt [1] => Temp22.txt [2] => temp1.txt [4] => temp2.txt [3] => temp15.txt ) Natural order case insensitve: Array ( [2] => temp1.txt [4] => temp2.txt [0] => Temp10.txt [3] => temp15.txt [1] => Temp22.txt )
点击查看所有 PHP 教程 文章: https://codercto.com/courses/l/5.html
XML Hacks
Michael Fitzgerald / O'Reilly Media, Inc. / 2004-07-27 / USD 24.95
Developers and system administrators alike are uncovering the true power of XML, the Extensible Markup Language that enables data to be sent over the Internet from one computer platform to another or ......一起来看看 《XML Hacks》 这本书的介绍吧!