PHP - Moved: Really Random Question
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=315227.0 Similar TutorialsThis topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=310934.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=319085.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=314527.0 Hi everyone Well I've started learning php yesterday and now I encountered my first problem, I looked around but I don't really know what to search for if I want my answer so here I come Code: [Select] <html> <body> <?php $names = array('Peter','Quagmire','Joe'); $ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34); $who = rand(0,2); $who2 = $names[$who]; echo "$names[$who] is $ages[$who2] years old"; ?> </body> </html> This is the script I have, and there is the kind of script I expected: Code: [Select] <html> <body> <?php $names = array('Peter','Quagmire','Joe'); $ages = array("Peter"=>32, "Quagmire"=>30, "Joe"=>34); $who = rand('Peter','Quagmire','Joe'); echo "$who is $ages[$who] years old"; ?> </body> </html> But after some search I concluded that rand is only used for random numbers So, my question is, which function should I use to achieve my goal? Is there any randstring('string1','string2',etc) command? Tnx for your time As above, I have a lottery style site that picks a random number between 1-8 but my users complain for some reason that this is not enough. So i was told to look into using fopen and random.org to generate a random number. Anyone have experience of this and perhaps a code snippet for me to look at and possibly use? help will be appreciated. This topic has been moved to JavaScript Help. http://www.phpfreaks.com/forums/index.php?topic=345714.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=342468.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=342707.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=307000.0 This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=353404.0 This topic has been moved to Ajax Help. http://www.phpfreaks.com/forums/index.php?topic=321915.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=305964.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=354997.0 This topic has been moved to Miscellaneous. http://www.phpfreaks.com/forums/index.php?topic=310658.0 This topic has been moved to HTML Help. http://www.phpfreaks.com/forums/index.php?topic=317591.0 This topic has been moved to CSS Help. http://www.phpfreaks.com/forums/index.php?topic=317879.0 This topic has been moved to PHP Regex. http://www.phpfreaks.com/forums/index.php?topic=357263.0 This topic has been moved to mod_rewrite. http://www.phpfreaks.com/forums/index.php?topic=321972.0 This topic has been moved to Other Web Server Software. http://www.phpfreaks.com/forums/index.php?topic=330622.0 Amazingly, threads about application design belong in the Application Design sub-forum. This topic has been moved to Application Design. http://www.phpfreaks.com/forums/index.php?topic=358384.0 |