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
sakarya escort sakarya escort sakarya escort sakarya escort serdivan escort izmir escort eporner
akyazı escort sakarya escort ferizli escort sakarya escort geyve escort sakarya escort hendek escort sakarya escort karasu escort sakarya escort sapanca escort serdivan escort webmaster forum
pendik escort atasehir escort