How to get a random key from a PHP array

How to get a random key from a PHP array

In this post, i will tell you how to get random key from PHP array.

array_rand method in PHP will return the keys of the random entries.

This method takes two argument : first will be the input array and second argument specifies how many entries you want to picked.

Each time when you refresh the page you will get different number.

Syntax :

array_rand(array,number)
Example :
  1. <?php
  2. $arr = array('a','b','c','d','e','f');
  3. $random_key = array_rand($arr, 3);
  4. print_r($random_key);
  5. ?>    

Phone: (+91) 8800417876
Noida, 201301
ataşehir escort maltepe escort bostancı escort kadıköy escort maltepe escort ataşehir escort kurtköy escort kartal escort pendik escort ataşehir escort
şişli escort
pendik escort
izmir escort izmir escort izmir escort izmir escort denizli escort antalya escort antalya escort antalya escort izmir escort izmir escort izmir escort izmir escort izmir escort