pcbytes Posted March 25, 2007 Share Posted March 25, 2007 Ok lets say for example I have the following: $sentance1 = "the black cat crossed the street"; Is there a way I can scramble the text up in the variable randomly. so lets say it now is $sentance1 = "crossed black cat the street the"; I don't know how I would go about doing this. Is there any command that can take the contents of the variable, garble it up, and spit it back out like that? Quote Link to comment https://forums.phpfreaks.com/topic/44202-solved-randomize-variable-value/ Share on other sites More sharing options...
MadTechie Posted March 25, 2007 Share Posted March 25, 2007 hows this <?php $sentance1 = "the black cat crossed the street"; $s = explode(" ",$sentance1); shuffle($s); $new_sentance1 = implode(" ", $s); echo $sentance1; echo "<br />is now<br />"; echo $new_sentance1; ?> Quote Link to comment https://forums.phpfreaks.com/topic/44202-solved-randomize-variable-value/#findComment-214653 Share on other sites More sharing options...
pcbytes Posted March 25, 2007 Author Share Posted March 25, 2007 cool shuffle(); is my function that will solve my problems then ;D Thanks a million! Quote Link to comment https://forums.phpfreaks.com/topic/44202-solved-randomize-variable-value/#findComment-214655 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.