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

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -