P粉3641297442023-08-25 21:11:22
$array = array(); shuffle($array); // 随机排列数组项的顺序 $newArray = array_slice($array, 0, 8);
Note that the shuffle()
function passes arguments as references and changes them.
P粉4933130672023-08-25 20:54:07
$result = array(); foreach( array_rand($my_array, 8) as $k ) { $result[] = $my_array[$k]; }