菜单切换
FACESOHO知行者
心灵
记录
远方
赞赏工具
源代码
运行
保存
<html> <body> <?php $arr1 = $arr2 = array("pic1","pic2","pic10","pic01","pic100","pic20","pic30","pic200"); echo "Standard string comparison"."<br>"; usort($arr1,"strcmp"); print_r($arr1); echo "<br>"; echo "<br>"; echo "Natural order string comparison"."<br>"; usort($arr2,"strnatcmp"); print_r($arr2); ?> </body> </html>
运行结果
<!DOCTYPE html> <html> <body> Standard string comparison<br>Array ( [0] => pic01 [1] => pic1 [2] => pic10 [3] => pic100 [4] => pic2 [5] => pic20 [6] => pic200 [7] => pic30 ) <br><br>Natural order string comparison<br>Array ( [0] => pic01 [1] => pic1 [2] => pic2 [3] => pic10 [4] => pic20 [5] => pic30 [6] => pic100 [7] => pic200 ) </body> </html>