View Single Post
Old 11-27-2007, 02:32 PM   #5 (permalink)
iisbum
The Wanderer
 
Join Date: Nov 2007
Posts: 20
Thanks: 1
iisbum is on a distinguished road
Default

My favorite way of doing this is to use the shuffle function, to use the example from above:

PHP Code:
$banner = array();
$banner[]=array("image.gif","http://domain.com/");  
$banner[]=array("image2.gif","http://www.domain.domain.co.uk/");
$banner[]=array("image3.gif","http://search.mysearch.com");
shuffle($banner);

$numBanners 1;
for (
$i=0$i<$numBanners$i++) {
  print 
"".$banner[$i][0];

This way you won't duplicate ads if you are showing more than one at a time. I haven't tested its efficiency, but since you randomize the array once I'm guessing its pretty efficient.

Mubs
iisbum is offline  
Reply With Quote