Run ❯
Get your
own PHP
server
Result Size:
625 x 565
×
Change Orientation
Change Theme, Dark/Light
Go to 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>
Standard string comparison
Array ( [0] => pic01 [1] => pic1 [2] => pic10 [3] => pic100 [4] => pic2 [5] => pic20 [6] => pic200 [7] => pic30 )
Natural order string comparison
Array ( [0] => pic01 [1] => pic1 [2] => pic2 [3] => pic10 [4] => pic20 [5] => pic30 [6] => pic100 [7] => pic200 )