php random array

Posted by user295189 on Stack Overflow See other posts from Stack Overflow or by user295189
Published on 2010-05-25T02:26:55Z Indexed on 2010/05/25 2:31 UTC
Read the original article Hit count: 476

Filed under:
|

I am trying to get a random array like this

srand((float) microtime() * 10000000);
$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 2);
echo $input[$rand_keys[0]] . "\n";
echo $input[$rand_keys[1]] . "\n";

it shows 2 numbers randomly if I have $rand_keys = array_rand($input, 2);$rand_keys = array_rand($input, 5); but since I want all 5 to show it doesnt work. whats causing that. I need to use array_rand. thanks

© Stack Overflow or respective owner

Related posts about php5

Related posts about php4