karimali831 Posted September 4, 2010 Share Posted September 4, 2010 Hi, I want to pick out a random letter from a to h. How can I do this? So everytime the page re-loads, a random letter (range a-h) will show. Thanks alot for any help. Link to comment https://forums.phpfreaks.com/topic/212549-php-shufflerandom/ Share on other sites More sharing options...
freeloader Posted September 4, 2010 Share Posted September 4, 2010 $alpha = array ('a','b','c','d','e','f','g','h'); $letter = $alpha[rand(0,7)]; Link to comment https://forums.phpfreaks.com/topic/212549-php-shufflerandom/#findComment-1107312 Share on other sites More sharing options...
karimali831 Posted September 4, 2010 Author Share Posted September 4, 2010 Thank you EDIT Should it be 0,8 as there are 8 letters? Link to comment https://forums.phpfreaks.com/topic/212549-php-shufflerandom/#findComment-1107313 Share on other sites More sharing options...
freeloader Posted September 4, 2010 Share Posted September 4, 2010 $alpha is the array of letters, I'm randomly chosing the key to take. Since default array keys start at 0, that value should included as well. Index goes from 0-7, 8 letters in total but index 7 is your last letter. Link to comment https://forums.phpfreaks.com/topic/212549-php-shufflerandom/#findComment-1107316 Share on other sites More sharing options...
karimali831 Posted September 4, 2010 Author Share Posted September 4, 2010 Gotcha, thanks again Link to comment https://forums.phpfreaks.com/topic/212549-php-shufflerandom/#findComment-1107320 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.