Page 1 of 1

Fixing another ad rotator

Posted: Mon Apr 05, 2010 1:07 pm
by Vegan
Ok I have this old code block, it shows ads from a text file, but it shows them all, I only wanted a random pick, what I am doing wrong?

Code: Select all

<?php
// This one uses a text file for the ads
$fcontents = join ('', file ('banner_ads.txt'));
$s_con = split("~",$fcontents);
$banner_no = rand(0,(count($s_con)-1));
echo $s_con[$banner_no];
?>

Re: Fixing another ad rotator

Posted: Mon Apr 05, 2010 1:09 pm
by Vegan
What I want to do is dump the ~ on a line and just use newline if possible?

Re: Fixing another ad rotator

Posted: Mon Apr 05, 2010 1:20 pm
by Vegan
Another problem, if I am outside of the site root, the rotator cannot find the ad file