(PHP 3 >= 3.0.8, PHP 4, PHP 5)
本函数打乱(随机排列单元的顺序)一个数组。
注意: 本函数为 array 中的单元赋予新的键名。这将删除原有的键名而不仅是重新排序。
array
例 1. shuffle() 例子
<?php $numbers = range(1,20); srand((float)microtime()*1000000); shuffle($numbers); foreach ($numbers as $number) { echo "$number "; } ?>
注意: 自 PHP 4.2.0 起,不再需要用 srand() 或 mt_srand() 函数给随机数发生器播种,现已自动完成。
参见 arsort(),asort(),ksort(),rsort(),sort() 和 usort()。