I found this on a forum and tested it out: <? $urls[]="http://www.url1.com/"; $urls[]="http://www.url2.com/"; //Add as many urls as you want this way $rnd=rand(0,count($urls)-1); $redirect=$url[$rnd]; echo "<html><head><meta http-equiv='refresh' content='0;url=".$redirect."'></head><body></body></html>"; ?> Code (markup): However, I get this: http://www.melen.net/randomtest.php The page keeps refreshing itself and goes nowhere. I just copied that same exact code. anyone have an idea to what I did wrong?
I don't want to use Location: though, I want to use meta-refresh because it hides referrals while Location: doesn't.
ok give me 1 minute and I will change that for you! Edit <? $url[0] = "http://test1.com/"; $url[1] = "http://test2.com/"; $url[2] = "http://test3.com/"; $url[3] = "http://test4.com/"; $url[4] = "http://test5.com/"; srand ((double)microtime()*1000000); $randomnum = rand(0, count($url)-1); ?> <meta http-equiv="refresh" content="0;url=<?=$url[$randomnum];?>"> PHP:
<? $urls[]="http://www.url1.com/"; $urls[]="http://www.url2.com/"; //Add as many urls as you want this way $rnd=rand(0,count($urls)-1); $redirect=$url[$rnd]; echo "<html><head><meta http-equiv='refresh' content='0;url=".$redirect."'></head><body></body></html>"; ?> PHP: $redirect=$url[$rnd]; //<--- error here it should be $redirect=$urls[$rnd];
example $a = array('r','s','t','u'); $i = count($a); echo $i; //<--- output 4 PHP: From that result, we know that count() is start from 1