Skip to content

Instantly share code, notes, and snippets.

@racinmat
Created March 29, 2016 13:04
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save racinmat/874de00981056dca8ed0 to your computer and use it in GitHub Desktop.
Save racinmat/874de00981056dca8ed0 to your computer and use it in GitHub Desktop.
Redirect to random url address from array
<?php
/**
* Created by PhpStorm.
* User: Azathoth
* Date: 29. 3. 2016
* Time: 14:54
*/
$addresses = [
'http://www.google.com',
'http://www.facebook.com',
'http://www.youtube.com'
];
$size = count($addresses);
$randomIndex = rand(0, $size - 1);
$randomUrl = $addresses[$randomIndex];
header('Location: ' . $randomUrl, true, 303);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment