Posted By

bluecap on 04/28/11


Tagged

php image banner ad rotator


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

tux-world


Simple PHP ad banner / image rotator


 / Published in: PHP
 

Pull banner ad or image code from a given text file into an array and randomize the order. Banner/image codes in the file should be separated by tildes (~).

  1. function initializeAds($file) {
  2. $fcontents = file_get_contents($file);
  3. $ad_array = explode("~",$fcontents);
  4. shuffle($ad_array);
  5.  
  6. return $ad_array;
  7. }
  8.  
  9. $ad_banners = initializeAds('ad_banners.txt');
  10.  
  11. echo $ad_banners[0]; // first randomly ordered banner
  12. echo $ad_banners[1]; // second randomly ordered banner, etc.

Report this snippet  

You need to login to post a comment.