Introduction to array_reverse () and shuffle () Functions
Array_reverse ()
The input parameters of the array array_reverse (array) array_reverse () function are an array, and an array with the same values but the opposite order is returned.
Copy codeThe Code is as follows:
<? Php
$ A = array (1, 2, 3, 4, 5 );
$ A = array_reverse ($ );
For ($ I = 0; $ I <count ($ a); ++ $ I)
Echo $ a [$ I]. "";
?>
Result:
5 4 3 2 1
Shuffle ()
The bool shuffle (array) shuffle function sorts the input arrays randomly. If yes, TRUE is returned. Otherwise, FALSE is returned.
Copy codeThe Code is as follows:
<? Php
$ A = array (1, 2, 3, 4, 5 );
Shuffle ($ );
For ($ I = 0; $ I <count ($ a); ++ $ I)
Echo $ a [$ I]. "";
Shuffle ($ );
Echo "<br/> ";
For ($ I = 0; $ I <count ($ a); ++ $ I)
Echo $ a [$ I]. "";
?>
Results returned by two calls:
4 1 2 5 3
1 5 2 4 3