how to rearrange randomly and show all the 5 elements

Posted by user295189 on Stack Overflow See other posts from Stack Overflow or by user295189
Published on 2010-05-25T13:00:36Z Indexed on 2010/05/25 13:11 UTC
Read the original article Hit count: 276

Filed under:
|

how can I rearrange it randomly and NOT use shuffle function and still be able to randomly arrange all the elements

$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");   
$rand_keys = array_rand($input, 5);   
echo $input[$rand_keys[0]] . "\n";   
echo $input[$rand_keys[1]] . "\n";   
echo $input[$rand_keys[2]] . "\n";   
echo $input[$rand_keys[3]] . "\n";   
echo $input[$rand_keys[4]] . "\n";   

so it shows random names everytime the function is ran. thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about cakephp