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

asp.net - Change the driver in the connection string to a data source in VB.Net -

Getting started consuming web services in a Ruby on Rails 3 application -

objective c - iPhone and it's wireless area -