Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

php get random element from array

<?php
//array_rand ( array $array [, int $num = 1 ] ) 
$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 2);
echo $input[$rand_keys[0]] . "
";
echo $input[$rand_keys[1]] . "
";
?>

Source by www.php.net #
 
PREVIOUS NEXT
Tagged: #php #random #element #array
ADD COMMENT
Topic
Name
4+6 =