View Single Post
Old 09-20-2006, 02:10 PM  
Lycanthrope
Confirmed User
 
Lycanthrope's Avatar
 
Industry Role:
Join Date: Jan 2004
Location: Wisconsin
Posts: 4,517
Not the cleanest most efficient code, but here

<?

$delim = "\n";
$cryfile = "random.txt";
$fp = fopen($cryfile, "r");
$contents = fread($fp, filesize($cryfile));
$cry_arr = explode($delim,$contents); fclose($fp); srand((double)microtime()*1000000);
$cry_index = (rand(1, sizeof($cry_arr)) - 1);
$herecry = $cry_arr[$cry_index];

echo $herecry . "\n";

?>

random.txt can contain any html.. complete on one line (no empty lines)

ie:

<a href="http://www.domain1.com"><img src="image1.jpg"></a>
<a href="http://www.domain2.com"><img src="image2.jpg"></a>
<a href="http://www.domain3.com"><img src="image3.jpg"></a>
<a href="http://www.domain4.com"><img src="image4.jpg"></a>
etc...
__________________
Lycanthrope is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote