How to Get a Random Item from an Array in PHP
Use this snippet for grabbing a random item from an array in php $fruits = ['apple', 'banana', 'carrot', 'date', 'elderberry']; echo array_rand(array_flip($fruits)); // => 'banana' PHP's `array_flip` makes the keys the values and the valu...
Written by Sean Behan on 11/10/2017