运行 ❯
获取您自己的
PHP
服务器
×
更改方向
更改主题,深色/浅色
转到 Spaces
<!DOCTYPE html> <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>
标准字符串比较
数组 ( [0] => pic01 [1] => pic1 [2] => pic10 [3] => pic100 [4] => pic2 [5] => pic20 [6] => pic200 [7] => pic30 )
自然顺序字符串比较
数组 ( [0] => pic01 [1] => pic1 [2] => pic2 [3] => pic10 [4] => pic20 [5] => pic30 [6] => pic100 [7] => pic200 )