View Single Post
Old 12-09-2010, 09:22 PM  
Tempest
Too lazy to set a custom title
 
Industry Role:
Join Date: May 2004
Location: West Coast, Canada.
Posts: 10,217
Quote:
Originally Posted by GrouchyAdmin View Post
Certainly takes out some minor overhead by calling count() manually for each parse. I'd suggest this as well for something as simple-tarded as mentioned.

Code:
<?php
$urls = array(
        'http://www.google.com',
        'http://www.msn.com',
        'http://www.bing.com',
        'http://www.webcrawler.com',
        'http://www.dogpile.com',
);
header("location: ". array_rand(array_flip($urls), 1));
?>
Or he could just do a shuffle.

Code:
<?php
$urls[] = "url1";
$urls[] = "url2";
$urls[] = "url3";
$urls[] = "url4";
$urls[] = "url5";

shuffle($urls);

header('location: '.$urls[0]);
?>
Gotta love how's there multiple solutions to the same thing.
Tempest is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote