Return to Snippet

Revision: 45319
at April 28, 2011 13:08 by bluecap

Initial Code
function initializeAds($file) {
  $fcontents = file_get_contents($file);
  $ad_array = explode("~",$fcontents);

  return $ad_array;

$ad_banners = initializeAds('ad_banners.txt');

echo $ad_banners[0]; // first randomly ordered banner
echo $ad_banners[1]; // second randomly ordered banner, etc.

Initial URL

Initial Description
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 (~).

Initial Title
Simple PHP ad banner / image rotator

Initial Tags
php, image

Initial Language