我有阵列:
Array ( [0] => 1 [2] => 3 [3] => 4 [5] => 6 [6] => 7 [7] => 8 [8] => 9 [9] => 10 [10] => 11 [11] => 12 [12] => 13 [13] => 14 [14] => 15 [15] => 16 [16] => 17 [17] => 18 [18] => 19 [20] => 21 [21] => 22 [22] => 23 )
我想绘制一个数字array_rand()
$rand_array = array_rand($new_array, 1);
但结果是0,5,20 - 这些数字不在数组中
答案 0 :(得分:2)
$intRandomIndex = array_rand($new_array, 1);
echo $new_array[$intRandomIndex];