note 110016 deleted from function.array-rand by aharvey
| From: | aharvey@php.net | Date: | Wed, 12 Sep 2012 05:12:23 +0000 |
| Subject: | note 110016 deleted from function.array-rand by aharvey | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-190646@lists.php.net to get a copy of this message | ||
Note Submitter: Anonymous
----
//array_rand
echo "array_rand";
echo"<br>";
$input = array("Neo", "Morpheus", "Trinity", "Cypher",
"Tank");//we have only 5 value in array so we can define at maximum 5
$rand_keys = array_rand($input, 5);//5 is used for displaying the element if we define 1 we can
display only one element at a time
echo "1=".$input[$rand_keys[0]] ;
echo "<br>2=".$input[$rand_keys[1]] ;
echo "<br>3=".$input[$rand_keys[2]] ;
echo "<br>4=".$input[$rand_keys[3]] ;
echo "<br>5=".$input[$rand_keys[4]] ;
echo "<br>6=".$input[$rand_keys[5]]."only we got 5 value so it displaying only
5 value" ;