How to code a PHP sequence array. Help.

4 replies
Been googling, and I haven't found how to do an array that goes in sequence. Found how to do a random one.

Code:
// Create the array $links = array(); // Populare the array $links[0] = "http://www.site.com/ads1.php"; $links[1] = "http://www.site.com/ads2.php"; $links[2] = "http://www.site.com/ads3.php"; // Count links $num = count($links); // Randomize order $random = rand(0, $num-1); // Print random link echo $links[$random];
What I'm trying to achieve is an array that goes in order from 1, 2, 3, 4, and so on. Then starts back at 1 when it reaches the end. Basically, when someone clicks on a link it goes through the array and loads the next number. It goes up by clicks for everyone. Meaning Person A gets 1, Person B gets 2, and so on.

I imagine this is fairly simple? Could someone show me or direct me to a website explaining? Thanks.
#array #code #php #sequence

Trending Topics