Easy Tutorial
❮ Pdo Begintransaction Php Preg_Split ❯

PHP natsort() Function

Complete PHP Array Reference Manual

Example

Sort an array:


Definition and Usage

The natsort() function sorts an array using a "natural order" algorithm. The key-value pairs retain their original keys.

In a natural order algorithm, the number 2 is less than the number 10. In a computer sorting algorithm, 10 is less than 2 because the first digit of "10" is less than 2.


Syntax

Parameter Description
array Required. Specifies the array to be sorted.

Technical Details

Return Value: Returns TRUE on success, FALSE on failure.
PHP Version: 4+
--- ---
Changelog: Since PHP 5.2.10, leading zeros in numeric strings (e.g., '00006') are ignored.
--- ---
❮ Pdo Begintransaction Php Preg_Split ❯