PHP natcasesort() Function
In this chapter you will learn:
- Definition for PHP natcasesort() Function
- Syntax for PHP natcasesort() Function
- Parameter for PHP natcasesort() Function
- Return for PHP natcasesort() Function
- Note for PHP natcasesort() Function
- Example - sorts an array by using a "natural order" algorithm
Definition
The natcasesort() function sorts an array by using a "natural order" algorithm. The values keep their original keys.
Syntax
PHP natcasesort() Function has the following syntax.
natcasesort(array)
Parameter
Parameter | Is Required | Description |
---|---|---|
array | Required. | Array to sort |
Return
This function returns TRUE on success, or FALSE on failure.
Note
This function is case-insensitive.
Example 1
Sorts an array by using a "natural order" algorithm.
<?php/* j a va 2s.c o m*/
$temp_files = array("A1","A11","A12","B","B0","java2s.com");
natsort($temp_files);
echo "Natural order: ";
print_r($temp_files);
echo "<br />";
natcasesort($temp_files);
echo "Natural order case insensitve: ";
print_r($temp_files);
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP natsort() Function
- Syntax for PHP natsort() Function
- Parameter for PHP natsort() Function
- Note for PHP natsort() Function
- Return value for PHP natsort() Function
- Example - sorts an array by using a "natural order" algorithm
Home » PHP Tutorial » PHP Array Functions