PHP explains how to use the array sorting function in two ways
Source: Internet
Author: User
The input parameters of the array_reverse () reverse sorting function are an array, and an array with the same value but the opposite order is returned. & Lt ;? Php $ aarray (1, 2, 3, 4, 5); $ javasray_reverse ($ a); for ($ i0; $ I & lt; count ($ a); $ I) echo $ a [$ I].;? & Gt; result: 54321 shuf array_reverse () reverse sorting function
The input parameters of the function are an array, and an array with the same value but the opposite order is returned.
$ A = array (1, 2, 3, 4, 5 );
$ A = array_reverse ($ );
For ($ I = 0; $ I Echo $ a [$ I]. "";
?>
Result:
5 4 3 2 1
Shuffle () random sort code function
The function sorts the input arrays randomly. if the input array is successfully sorted, TRUE is returned. otherwise, FALSE is returned.
$ A = array (1, 2, 3, 4, 5 );
Shuffle ($ );
For ($ I = 0; $ I Echo $ a [$ I]. "";
Shuffle ($ );
Echo"
";
For ($ I = 0; $ I Echo $ a [$ I]. "";
?>
Results returned by two calls:
4 1 2 5 3
1 5 2 4 3
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.