View Single Post
Old 2006-01-09, 03:45 PM   #2
Halfdeck
You can now put whatever you want in this space :)
 
Halfdeck's Avatar
 
Join Date: Oct 2004
Location: New Haven, CT
Posts: 985
Send a message via ICQ to Halfdeck
Top of the page (before any HTML):

PHP Code:
<?php

function random_link() {
   
$links = array("teen link" => "http://link1.com""mature babes" => "link2.com","horny sluts" => "link3.com");
   
shuffle($links); // randomize
   
list($linktext$url) = each($links); // pull the first link on the list
   
echo "<a href='$url'>$linktext</a>"// display it
}

?>
Then use <? random_link(); ?> in your HTML where ever you want the link displayed.

P.S. I'm not sure how random the shuffle() function is.

You can also create a random_link.php file, dump the code in there, then do an include where you want the link displayed:

<? include('path to file..../random_link.php'); ?>

Personally though, I would stick with JS, because with PHP you're adding a slight load on the server. Also, I'm sure you can use an external JS file and just call the function in your HTML. Only time I'd use PHP for something like this is if I was dealing with hundreds of links.
__________________
Success is going from failure to failure without a loss of enthusiasm.
Halfdeck is offline   Reply With Quote