pilots Posted January 28, 2008 Report Posted January 28, 2008 <?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?
bubu Posted January 29, 2008 Report Posted January 29, 2008 Nevajag padot stringu tur, kur vajadzīgs integers. Un nevajag lieki konkatenēt stringus. <?php $input = array('xxx', 'yyy', 'zzz'); $rand_keys = array_rand($input, 1); echo $input[$rand_keys[0]], "\n"; ?>
pilots Posted January 29, 2008 Author Report Posted January 29, 2008 Notice: Undefined index: in ... rindiņā - echo $input[$rand_keys[0]], "\n"; kā tad to izlabot?
pilots Posted January 29, 2008 Author Report Posted January 29, 2008 Paldies, Val. Tagad strādā ok tas skripts.
Recommended Posts