超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<listnatsort>
Last updated: Fri, 22 Jun 2007

natcasesort

(PHP 4 , PHP 5)

natcasesort --  用“自然排序”算法对数组进行不区分大小写字母的排序

说明

void natcasesort ( array array)

本函数实现了一个和人们通常对字母数字字符串进行排序的方法一样的排序算法,这被称为“自然排序”。

natcasesort()natsort() 函数的不区分大小写字母的版本。见 natsort() 中说明本算法和通常的计算机字符串排序算法的区别的例子。

更多信息见 Martin Pool 的 Natural Order String Comparison 页面。

参见 sort()natsort()strnatcmp()strnatcasecmp()




add a note add a note User Contributed Notes
natcasesort
Ulli at Stemmeler dot net
06-Apr-2002 12:01
natcasesort didn't work first time I needed something like this.
Not on my local server, not on my server on the web.
I needed an array sorted ignoring upper and lower cases. In the end lower case array-members stayed at the end of the array.

I replaced it with this function:
---------
function ignorecasesort(&$array) {
$separator="|<>|";
for($i=0;$i<sizeof($array);$i++) { $array[$i]=strtolower($array[$i]).$separator.$array[$i]; }
sort($array);
for($i=0;$i<sizeof($array);$i++) { $this=$array[$i]; $this=explode($separator,$this); $array[$i]=$this[1]; }
}
---------

<listnatsort>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22