(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()。