StellarTech Blog

Tag: tutorials

Creating a rotating ad in PHP

by Glen on Sep.12, 2006, Tags: ,

First open up your up a file in your text editor of choice. In this example I’m going to call the file ad.php and just include it in the page I wish for it to show up in.

Second I’ll define my ads:

<?php
$ad[1] = “We got the goods here”;
$ad[2] = “Give us your money”;
$ad[3] = “blah blah blah”;

Now that you’ve got an array defined for your ads we will use rand() to call them up randomly:


$random = rand(1, sizeof($ad));
echo $ad[$random];
?>

That’s it. Hope this is helpful.

Leave a Comment :, more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!