Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

PHP strnatcmp — String comparisons using a "natural order" algorithm

<?php
$arr1 = $arr2 = array("img12.png", "img10.png", "img2.png", "img1.png");
echo "Standard string comparison
";
usort($arr1, "strcmp");
print_r($arr1);
echo "
Natural order string comparison
";
usort($arr2, "strnatcmp");
print_r($arr2);
?>
 
PREVIOUS NEXT
Tagged: #PHP #strnatcmp #String #comparisons #algorithm
ADD COMMENT
Topic
Name
5+2 =