(PHP 3 >= 3.0.8, PHP 4, PHP 5)
本函数打乱(随机排列单元的顺序)一个数组。必须用 srand() 播下本函数的随机数发生器种子。
例子 1. shuffle() 例子
<?php$numbers = range (1,20);srand ((float)microtime()*1000000);shuffle ($numbers);while (list (, $number) = each ($numbers)) { echo "$number ";}?>
注: 自 PHP 4.2.0 起,不再需要用 srand() 或 mt_srand() 函数给随机数生成器播种,现已自动完成。
参见 arsort(),asort(),ksort(),rsort(),sort() 和 usort()。