(PHP 4, PHP 5, PHP 7)
natcasesort — 锟斤拷"锟斤拷然锟斤拷锟斤拷"锟姐法锟斤拷锟斤拷锟斤拷锟斤拷胁锟斤拷锟斤拷执锟叫⌒达拷锟侥革拷锟斤拷锟斤拷锟�
&$array
) : boolnatcasesort() 锟斤拷 natsort() 锟斤拷锟斤拷锟侥诧拷锟斤拷锟街达拷小写锟斤拷母锟侥版本锟斤拷
锟斤拷锟斤拷锟斤拷实锟斤拷锟斤拷一锟斤拷锟斤拷锟斤拷锟斤拷通锟斤拷锟斤拷锟斤拷母锟斤拷锟斤拷锟街凤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷姆锟斤拷锟揭伙拷锟斤拷锟斤拷锟斤拷锟斤拷惴拷锟斤拷锟斤拷锟皆拷屑锟斤拷锟街碉拷墓锟斤拷锟斤拷锟斤拷獗伙拷锟轿�"锟斤拷然锟斤拷锟斤拷"锟斤拷
Note:
If two members compare as equal, their relative order in the sorted array is undefined.
array
锟斤拷锟斤拷锟斤拷锟斤拷椤�
锟缴癸拷时锟斤拷锟斤拷 TRUE
锟斤拷 锟斤拷锟斤拷锟斤拷失锟斤拷时锟斤拷锟斤拷 FALSE
锟斤拷
Example #1 natcasesort() 锟斤拷锟斤拷
<?php
$array1 = $array2 = array('IMG0.png', 'img12.png', 'img10.png', 'img2.png', 'img1.png', 'IMG3.png');
sort($array1);
echo "Standard sorting\n";
print_r($array1);
natcasesort($array2);
echo "\nNatural order sorting (case-insensitive)\n";
print_r($array2);
?>
锟斤拷锟斤拷锟斤拷锟教伙拷锟斤拷锟斤拷锟�
Standard sorting Array ( [0] => IMG0.png [1] => IMG3.png [2] => img1.png [3] => img10.png [4] => img12.png [5] => img2.png ) Natural order sorting (case-insensitive) Array ( [0] => IMG0.png [4] => img1.png [3] => img2.png [5] => IMG3.png [2] => img10.png [1] => img12.png )
锟斤拷锟斤拷锟斤拷息锟斤拷 Martin Pool 锟斤拷 » Natural Order String Comparison 页锟芥。