Introduction to the features of PHP natural language sorting. The ListingG is an example of sorting PHP natural language :? Php $ dataarray (book-1, book-10, book-100, book-5); sort ($ data); print_r ($ data); natsort ($ data ); priListing G is an example of PHP natural language sorting:
-
php
- $data = array("book-1", "book-10", "book-100",
"book-5"); sort($data);print_r($data);
- natsort($data); print_r($data);?>
The output result is as follows:
Array ([0] => book-1
[1] => book-10
[2] => book-100
[3] => book-5
)
Array
(
[0] => book-1
[3] => book-5
[1] => book-10
[2] => book-100
)
Their differences are clear: The second sorting result is more intuitive and "humanized". However, the first sorting result is more in line with algorithm rules and is more "computer. This is the sorting of PHP natural language.
Sort Listing G is an example of PHP natural language sorting :? Php $ data = array ("book-1", "book-10", "book-100", "book-5"); sort ($ data ); print_r ($ data); natsort ($ data); pri...