Fixing another ad rotator

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Fixing another ad rotator

Post 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];
?>
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: Fixing another ad rotator

Post by Vegan »

What I want to do is dump the ~ on a line and just use newline if possible?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
User avatar
Vegan
Forum Regular
Posts: 574
Joined: Fri Sep 05, 2008 3:34 pm
Location: Victoria, BC
Contact:

Re: Fixing another ad rotator

Post by Vegan »

Another problem, if I am outside of the site root, the rotator cannot find the ad file
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Post Reply