主要思路打乱数组的key
$a = [1,2,3,4,5,6,7];
$l = count($a);
for($i =0;$i<$l;$i++){
$key1 = rand(0,$l);
$key2 = rand(0,$l);
$temp = $a[$key1];
$a[$key1] = $a[$key2];
$a[$key2] = $temp;
}
主要思路打乱数组的key
$a = [1,2,3,4,5,6,7];
$l = count($a);
for($i =0;$i<$l;$i++){
$key1 = rand(0,$l);
$key2 = rand(0,$l);
$temp = $a[$key1];
$a[$key1] = $a[$key2];
$a[$key2] = $temp;
}
本文标题:打乱数组的顺序
本文链接:https://www.haomeiwen.com/subject/ugoalctx.html
网友评论