PHP  
downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
search for in the  
<rsortsizeof>
Last updated: Mon, 16 Jul 2012

shuffle

(PHP 3 >= 3.0.8, PHP 4, PHP 5)

shuffle -- 将数组打乱

说明

void shuffle ( array array )

本函数打乱(随机排列单元的顺序)一个数组。必须用 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()




<rsortsizeof>
 Last updated: Mon, 16 Jul 2012
 
Copyright © 2001-2005 The PHP Group
All rights reserved.
This unofficial mirror is operated at: http://manual.phpv.net/
Last updated: Thu Jul 7 19:13:47 2005 CST