Need help Php redirect to random url

Scariot

Regular Member
Joined
Oct 5, 2013
Messages
467
Reaction score
288
Hi guys I'm not quite a coder (newbie) I need some help on url redirect using phpExample site.com/redirect.php then redirect to a random url in list Please help thank you.
 
<?php


$links = array('Your url 1',
'Your url 2',
'Your url 3');


$randNum = rand(0, count($links));
header("Location: " . $links[$randNum]);


?>
 
<?php


$links = array('Your url 1',
'Your url 2',
'Your url 3');


$randNum = rand(0, count($links));
header("Location: " . $links[$randNum]);


?>

it's not working with 4 or more only works at 3 can you give me a sample for list or url? maybe in text file?
 
Thanks I found one
 
Thanks I found one

ohhh sorry I just typed in rush and did not check my code, following is fixed one and should work perfectly...i have checked it this time

<?php


$links = array('your link',
'your link',
'your linkl',
'your link');


$randNum = rand(0, 4);
header("Location: " . $links[$randNum]);


?>
 
Back
Top