A normal procedure with banner adverts is to rotate them randomly, but also to display some more than others. Lets say that you had 3 banner adds and that you wanted to display them at different rates. To do this you can use the rand() function to generate a random number that can then be used to see what banner advert will be displayed.
First we generate the random number, in our case it is between 1 and 100.
$number = rand(1, 100);
You can then use this number to figure out what banner ad to display. Because the random number is between 1 and 100 it is basically a percentage. So you can create a simple if statement that will determine what banner should be displayed.
if ($number <p>You can then feed this into an image tag or something similar to enable the banner to display.</p> <code class="php"></code>
0 comments:
Post a Comment