Efficiently get a Random Array Element

An efficient way to show a random value from an array, using PHP's array_rand() functions.
1. $Numbers = array(4, 8, 15, 16, 23, 42);
2. echo $Numbers[array_rand($Numbers)]; // Will output a random number picked from the six above

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top