How to use array rand in PHP

In this article, I will explain how the array_rand() function can be used in PHP.
  • 2157

array_rand() function in PHP

  • The array_rand() function is used to returns a random entries from an array, or it returns an array of random keys if you specify that the function should return more than one key.

  • The array_rand() function fetch one or more random entries out of an array.

  • In array_rand() function, If the value of keys is 1, It return a random key.




  • array  array is required parameter. Specifies an array.

  • number number is optional parameter. It's specifie how many random keys to return.


The following example show to how the array_rand() function can be used in PHP.



<h3 style="color: greenyellow;">array_rand() function example in PHP</h3>  










You may also want to read these related articles here
Ask Your Question 
Got a programming related question? You may want to post your question here


More Articles

© 2020 DotNetHeaven. All rights reserved.