Created
March 29, 2016 13:04
-
-
Save racinmat/874de00981056dca8ed0 to your computer and use it in GitHub Desktop.
Redirect to random url address from array
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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