Page 1 of 1

How to redirect to a random link using php

Posted: Mon Feb 22, 2010 9:51 pm
by Neo

Code: Select all

<?php
// your links array
$links = array(
  'https://robot.lk.com',
  'http://coderlink.com',
  'http://buytiptop.com',
);

// select random link and redirect
header('Location: ' . $links[rand(0,count($links)-1)]);
?>