View Single Post
Old 07-24-2008, 08:04 AM  
ScriptWorkz
Confirmed User
 
Industry Role:
Join Date: Jul 2007
Location: Intraweb
Posts: 274
Quote:
Originally Posted by mikeyddddd View Post
I do it like this:

<?
$urls = file ("random.txt"); //replace with the name of your file
srand(time());
$count = count($urls);
$random = (rand()&#37;$count);
Header("Location: $urls[$random]");
?>

random.txt contains a list of URLs.

You could put the URLs into an array in the code if you prefer. I have them in a separate file so I can use them from other code.

Example is in my sig.



this is pretty much the best way to do it, personally i'd just make the code like this if you just need simple

PHP Code:
<?php
$urls 
file("./random.txt");
exit(
header("Location: " $urls[rand(0, (count($urls)-1))]));
?>
ScriptWorkz is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote