This question already has an answer here:
- How to get random value out of an array 14 answers
$items = Array(523,3452,334,31,...5346);
Each item of this array is some number.
How do I get random item from $items
?
This question already has an answer here:
$items = Array(523,3452,334,31,...5346);
Each item of this array is some number.
How do I get random item from $items
?
Use PHP Rand function
More Help
use
array_rand()
see php manual -> http://php.net/manual/en/function.array-rand.php
If you don't mind picking the same item again at some other time:
$items[rand(0, count($items) - 1)];
array_rand()