Random redirect to url

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
jeff.mikolai
Forum Newbie
Posts: 2
Joined: Mon Sep 25, 2006 11:28 am

Random redirect to url

Post by jeff.mikolai »

I need a little help finishing this script, or even any better ways of doing it. I simply want to randomly send a user to a url. Here is what I have so far:

<?
$random_url = array("http://www.url1.com",
"http://www.url2.com",
"http://www.url3.com",
"http://www.url4.com",
"http://www.url5.com");

srand(time());
$random = (rand()%5);

print("URL: $random_url[$random]");
?>

How do I perform the redirect or should I use an iframe and if so how.

Thank you,
Jeff Mikolai
User avatar
ambivalent
Forum Contributor
Posts: 173
Joined: Thu Apr 14, 2005 8:58 pm
Location: Toronto, ON

Re: Random redirect to url

Post by ambivalent »

jeff.mikolai wrote:
How do I perform the redirect ....
Use header()
jeff.mikolai
Forum Newbie
Posts: 2
Joined: Mon Sep 25, 2006 11:28 am

Post by jeff.mikolai »

Thanks! Got it working!
Post Reply