Sort with natural algorithm (strnatcmp) and computer string sorting algorithms (strcmp) in PHP
Description
The following code shows how to sort with natural algorithm (strnatcmp) and computer string sorting algorithms (strcmp).
Example
/*from www .j a v a2 s. c o m*/
<?php
$arr1 = $arr2 = array("pic01","pic100","pic20","pic30","pic200");
echo "Standard string comparison"."<br>";
usort($arr1,"strcmp");
print_r($arr1);
echo "<br>";
echo "Natural order string comparison"."<br>";
usort($arr2,"strnatcmp");
print_r($arr2);
?>
The code above generates the following result.