par
Invité » 30 avr. 2009, 14:27
Bonjour à tous,
j'ai trouvé l'exemple suivant pour faire une sélection aléatoire dans un array:
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";
A quoi sert la première ligne?
Merci pour vos réponses.
Bonjour à tous,
j'ai trouvé l'exemple suivant pour faire une sélection aléatoire dans un array:
[php]
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";
[/php]
A quoi sert la première ligne?
Merci pour vos réponses.