DJTim666 Posted June 9, 2007 Share Posted June 9, 2007 I want to know how I can run random strings set by me. Here is the code that I want to randomize. <?php $answer1 = "Yes"; $answer2 = "No"; $answer3 = "Maybe"; $answer4 = "I'm not sure"; $answer5 = "Possibly"; $answer6 = "For sure"; $answer7 = "Precisly"; $answer8 = "Why ask me? I'm just a computer."; $answerRandom = rand($answer1, $answer8); ?> Any help would be appreciated! -- DJ Link to comment https://forums.phpfreaks.com/topic/54909-solved-random-strings/ Share on other sites More sharing options...
ardyandkari Posted June 9, 2007 Share Posted June 9, 2007 im pretty new to php, but couldnt you just create a random interger? ok here is the idea $random=rand (1, 7) then use that to choose the string??? would that work? echo $answer$random i dont know for sure, like i said, im pretty new...dont know syntax and whatnot...its an idea though. Link to comment https://forums.phpfreaks.com/topic/54909-solved-random-strings/#findComment-271555 Share on other sites More sharing options...
DJTim666 Posted June 9, 2007 Author Share Posted June 9, 2007 No, I'm affraid that des;t work. It is just displaying the number. Link to comment https://forums.phpfreaks.com/topic/54909-solved-random-strings/#findComment-271560 Share on other sites More sharing options...
DJTim666 Posted June 10, 2007 Author Share Posted June 10, 2007 Got it to work finally. I had to use the switch() funtion ! Link to comment https://forums.phpfreaks.com/topic/54909-solved-random-strings/#findComment-271602 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.