Returns a set of keys for random entries of array. If you want to pick all entries in a randomized fashion you should be using:
1 2 3 4 5 6 7 8 9 10 11 12 | //Get array value out from array random //example random 4 array $randValues = array_intersect_key ( $input , array_flip ( array_rand ( $input , 4))); # pick a random key in your array : $rand_key = array_rand ( $your_array ); # extract the corresponding value: $rand_value = $your_array [ $rand_key ]; # remove the key-value pair from the array : unset( $your_array [ $rand_key ]); |
ref: http://stackoverflow.com/questions/18046630/php-array-rand-random-value/25678043#25678043
What do you think?