Jump to content

How to change a random code to choose/show items in an ordered fashion?


newdahas

Recommended Posts

<?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!!  :)

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.