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

Popular posts from this blog

php - multilevel menu with multilevel array -

c# - TypeConverter in propertygrid only converts from string, not to -

jQuery UI: Datepicker month format -