MrXander Posted September 11, 2007 Share Posted September 11, 2007 Any help on this one guys (and girls)? I'm trying to pick a random end to my sentence from an array.... (Ignore the $homa variable, that's not really involved...) $locationArray = array("under a park bench", "next to some bushes", "in the gutter"); $randLocation = array_rand($locationArray); echo $homa.$randLocation; But all $randLocation returns is a numeric value. Any suggestions? Quote Link to comment Share on other sites More sharing options...
corbin Posted September 11, 2007 Share Posted September 11, 2007 The numeric value is a random key from the array.... Try something like: $locationArray = array("under a park bench", "next to some bushes", "in the gutter"); $randLocation = array_rand($locationArray); echo $homa.$locationArray[$randlocation]; Quote Link to comment Share on other sites More sharing options...
MrXander Posted September 11, 2007 Author Share Posted September 11, 2007 The numeric value is a random key from the array.... Try something like: $locationArray = array("under a park bench", "next to some bushes", "in the gutter"); $randLocation = array_rand($locationArray); echo $homa.$locationArray[$randlocation]; Spot on. Thanks Quote Link to comment 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.