How to use natcasesort in PHP
In this article, I will explain how the natcasesort() function can be used in PHP.
natcasesort() function in PHP
- The natcasesort() function is used to sort an array by using a "natural order" algorithm.
- The natcasesort function is maintaining key/value associations
- The natcasesort() function returns TRUE on success.
- The natcasesort() function returns FALSE on failure.
Syntax
Parameter
- array array is required parameter. it is the input array to sort.
Example
The following example show to how the natcasesort() function can be used in PHP.
<html>
<body>
<h3 style="color: green;">natcasesort() function example in PHP</h3>
<?php
$temp_array = array("temp20.txt"."<br />","Temp11.txt"."<br />",
"temp1.txt"."<br />","Temp19.txt"."<br />","temp5.txt"."<br />");
natsort($temp_array);
echo "Natural order:<br/> ";
print_r($temp_array);
echo "<br />";
natcasesort($temp_array);
echo "Natural order case after natcasesort function: <br/>";
print_r($temp_array);
?>
</body>
</html>
|
Output
You may also want to read these related articles here
Ask Your Question
Got a programming related question? You may want to post your question here