PHP function shuffle () to achieve re-sorting. In shuffle -- disrupt the array: the shuffle (arrayarray) PHP function shuffle () disconnects an array (the order of randomly arranged units. Note: The PHP function shuffle () is the unit in the array
Shuffle -- disrupt the array:
Bool shuffle (array & array)
The PHP function shuffle () is used to disrupt an array (the order of randomly arranged units.
Note: The PHP function shuffle () assigns a new key name to the cell in the array. This will delete the original key name, not just the reorder.
Example:
- <? Php
- $ A = array (
- '1' => 'Xiao ',
- '2' => 'da ',
- '3' => 'zuo ',
- '4' => 'you'
- );
- Echo "original array:". "<br/> ";
- Print_r ($ );
- Shuffle ($ );
- Echo "<br/>". "current array:". "<br/> ";
- Print_r ($ );
- ?>
Check the running result of the PHP function shuffle:
Original array:
Array ([1] => Xiao [2] => Da [3] => Zuo [4] => You)
Current array:
Array ([0] => Da [1] => Xiao [2] => You [3] => Zuo)
Of course, each time the page is refreshed, the order of elements in the "current array" changes once. Note that the key name of the array has changed.
Sort shuffle -- disrupt the array: the shuffle (array) PHP function shuffle () disrupts an array (the order of randomly arranged units. Note: PHP function shuffle () is the unit in array...