This site uses cookies from Google to deliver its services, to personalize ads and to analyze traffic. Information about your use of this site is shared with Google. By using this site, you agree to its use of cookies. Learn More

[Php] How to get a random value from array in PHP?

If you don't mind picking the same item again at some other time then you can use following code:

 <?php $items = array(1,5); echo $items[rand(0, count($items) - 1)]; ?> 
It will display a random number from the elements of array. 1 or 3 or 5 or 1 .......

source : http://developer-paradize.blogspot.com, http://cnn.com, http://wikipedia.org



0 Response to "[Php] How to get a random value from array in PHP?"

Posting Komentar

Contact

Nama

Email *

Pesan *