Archive for September, 2008

random redirects to sites with php script

Sunday, September 28th, 2008

I was asked to create a script that would produce an even number of visits to each of three sites. I decided that I would skip the checking of making sure each site had a fair amount and instead generate the url randomly, since by the laws of averages, the number of redirects to each should work out to be roughly even over the course of time. So, onto the script…

$sites = array(
header('Location: '.$sites[array_rand($sites)]);

As you can see, it’s very simple. It is also open for you to add more sites into the $sites array
If you need any help with this or any other code that I have written, contact me via the address in the About page