Output array elements randomly with PHP -
How can I resonate 5 elements from an array of approximately 5 elements?
Thank you.
Does this work?
$ values = array_rand ($ input, 5);
Or, as a more flexible function
function random value ($ input, $ num = 5) {return array_rand ($ input, $ num) ); } // use $ array = range ('a', 'z'); // print 5 random characters from the alphabet print print_R (random value ($ array));
Comments
Post a Comment