array_rand
mixed array_rand ( array input [, int num_req] )
Is used to pick one or more random entries from an array.It takes an input array
and argument num_req is number of random entries we want to pick
which is optional one the default is 1.
If you pick one entry then the key of the entry is picked if the option is more than one then array of key are returned.
<?php
$array = array(’hai’,'this’,'is’,'an’,'example’);
$index = array_rand($array);
echo $array[$index];
//// Will output ‘hai’ or ‘this’ or ‘is’ or ‘an’ or ‘example’
?>
