note 110698 added to function.rand

From: Date: Fri, 23 Nov 2012 16:57:26 +0000
Subject: note 110698 added to function.rand
Groups: php.notes 
Request: Send a blank email to php-notes+get-192122@lists.php.net to get a copy of this message
I need to get one out of random but I get 3 why? <?php $vowels = array("a", "e", "o", "u", "i", "y"); $consonants = array("b", "c", "d", "v", "g", "t", "f", "h", "k", "m", "n", "w", "v", "z"); $numbers = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); function randVowel() { global $vowels; return $vowels[array_rand($vowels, 1)]; } function randConsonant() { global $consonants; return $consonants[array_rand($consonants, 1)]; } function randNumber() { global $numbers; return $numbers[array_rand($numbers, 1)]; } function a1() { echo ("" . randConsonant() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randNumber() . "<br>"); } function a2() { echo ("" . randConsonant() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randNumber() . "<br>"); } function a3() { echo ("" . randConsonant() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randConsonant() . "" . randVowel() . "" . randNumber() . "<br>"); } ?> <?php echo rand(a1(),a2(),a3()); ?> ---- Server IP: 217.146.68.100 Probable Submitter: 194.126.99.194 ---- Manual Page -- http://www.php.net/manual/en/function.rand.php Edit -- https://master.php.net/note/edit/110698 Del: integrated -- https://master.php.net/note/delete/110698/integrated Del: useless -- https://master.php.net/note/delete/110698/useless Del: bad code -- https://master.php.net/note/delete/110698/bad+code Del: spam -- https://master.php.net/note/delete/110698/spam Del: non-english -- https://master.php.net/note/delete/110698/non-english Del: in docs -- https://master.php.net/note/delete/110698/in+docs Del: other reasons-- https://master.php.net/note/delete/110698 Reject -- https://master.php.net/note/reject/110698 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#192122) next »