Refused Posted May 24, 2006 Share Posted May 24, 2006 Just a quick query, while i learn about databases for PHP i am making a small script with the PHP i do know.What i have tried but just cant figure it out though (i need for the script im making) is a randomization. Basiclly i want is to have a randomized word to output on the page onced a user has filled in some info and pressed the submit button.Now i know how to do it all except for how to make a random word, i would like to add a fair amount of words in it.So would anyone either post, or explain how to make a random word appear.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/10328-randomization/ Share on other sites More sharing options...
eves Posted May 24, 2006 Share Posted May 24, 2006 [code] $words = array("zero","one","two","three","four","five","six","seven","eight","nine");echo $words[rand(0,(count($words)-1))];[/code]store some words on an array, then just generate a random indexfrom zero to max index of array ( (count($words)-1)) ) Quote Link to comment https://forums.phpfreaks.com/topic/10328-randomization/#findComment-38568 Share on other sites More sharing options...
Refused Posted May 24, 2006 Author Share Posted May 24, 2006 Thankyou for your help.That is very close how i had been doing it, i knew an array needed to be used to store the words but i couldent figure out that second part.Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/10328-randomization/#findComment-38700 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.