newdahas Posted October 2, 2008 Share Posted October 2, 2008 <?php $quotes = array( 'text1', 'text2', 'text3', 'text4', 'text5', 'text6', 'text7', 'text8', ); /* generate a random number between zero and the number of quotes minus one */ $rand = rand(0, (count($quotes)-1)); // output the random quote echo $quotes[$rand]; ?> I have the code above, which shows random text. Now I would like to change that so that it would show the text in an ordered fashion each time I would load the page -- that is on first load "text1" would show, on the text reload "text2", etc. all the way up to "text8" and then it would start again at "text1". Do you think you could help me out? Thank you!! Link to comment https://forums.phpfreaks.com/topic/126783-how-to-change-a-random-code-to-chooseshow-items-in-an-ordered-fashion/ Share on other sites More sharing options...
F1Fan Posted October 2, 2008 Share Posted October 2, 2008 You could use a session similar to this topic: http://www.phpfreaks.com/forums/index.php/topic,219135.0.html Link to comment https://forums.phpfreaks.com/topic/126783-how-to-change-a-random-code-to-chooseshow-items-in-an-ordered-fashion/#findComment-655761 Share on other sites More sharing options...
newdahas Posted October 3, 2008 Author Share Posted October 3, 2008 You could use a session similar to this topic: http://www.phpfreaks.com/forums/index.php/topic,219135.0.html Thanks F1Fan! I've moved my inquiry there. Link to comment https://forums.phpfreaks.com/topic/126783-how-to-change-a-random-code-to-chooseshow-items-in-an-ordered-fashion/#findComment-656205 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.