Reputation: 27048
i have a link:
<a href="">Click Me!</a>
and i have a few links: google.com
, yahoo.com
, etc...
what i want is each time i click on the Click Me!
to grab a random link and go to it
any ideas? thanks
Upvotes: 0
Views: 174
Reputation:
You can make use of array_rand
to pick out a random item from an array:
$urls = array('http://google.com', 'http://yahoo.com');
echo '<a href="' . $urls[array_rand($urls)] . '">Click Me!</a>';
Upvotes: 4