Help! Need a bit of code.

Namecheap AuctionsNamecheap Auctions
Namecheap AuctionsNamecheap Auctions
NamecheapNamecheap
Watch

Jeffler

Established Member
Impact
7
I need something that will redirect someone to a random page. So if they're at index.html/php/whatever, and the code has a list of a.com, b.com, or c.com, it picks a random one and redirects them to the site.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Haven't tested, but should work:

PHP:
<?php
$domains = array('www.a.com', 'www.b.com', 'www.c.com');
$location = $domains[random(0, count($domains)-1)];
header('Location: http://' . $location);
?>
 
0
Close
Mikor said:
Haven't tested, but should work:

PHP:
<?php
$domains = array('www.a.com', 'www.b.com', 'www.c.com');
$location = $domains[random(0, count($domains)-1)];
header('Location: http://' . $location);
?>

Well how do you get it to redirect from there?
 
0
Close
0
Close
The only problem with that code is that the function is rand( and not random(.

:gl:
 
0
Close
CatchedCatched

We're social

Escrow.com
Spaceship
CryptoExchange.com
Domain Recover

NamePros updates

Quick replies: search, your most used replies, and more on every post
Quick replies are easier to find and use now. The quick reply menu has a search box. Type a few letters to find the reply you want. A...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back