Displaying and Randomising php Arrays

后端 未结 4 620
庸人自扰
庸人自扰 2021-01-22 10:04

I have an array displaying results as below:

Array
(
    [0] => 71
    [1] => 56
    [2] => 64
    [3] => 82
    [4] => 90
    [5] => 80
    [6         


        
4条回答
  •  萌比男神i
    2021-01-22 10:21

    $rand5 = array_rand(array_flip($show), 5);
    // we need array_flip because array_rand returns the keys
    

    http://php.net/array_rand

    http://php.net/array_flip

提交回复
热议问题