Jump to content
php.lv forumi

random, array_rand vai shuffle


pilots

Recommended Posts

<?php

$input = array('xxx', 'yyy', 'zzz');

$rand_keys = array_rand($input, 1);

echo $input[$rand_keys['0']] . "\n";

?>

 

vai

 

<?php

$input = array('xxx', 'yyy', 'zzz');

shuffle($input);

echo $input[0] . "\n";

?>

 

ir kāds vēlamāks par otru variants?

Link to comment
Share on other sites

×
×
  • Create New...