Created
August 12, 2014 07:58
-
-
Save JacobHsu/a05fbebbaa3871d55c61 to your computer and use it in GitHub Desktop.
#PHP - random value from array of name
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
<html> | |
<p> | |
<?php | |
// Create an array and push on the names | |
// of your closest family and friends | |
$arr = array(); | |
array_push($arr,"Tom"); | |
array_push($arr,"Mary"); | |
array_push($arr,"Tony"); | |
// Sort the list | |
sort($arr); | |
// Randomly select a winner! | |
$winner = rand( 1, count($arr)); | |
// Print the winner's name in ALL CAPS | |
print strtoupper($arr[$winner]); | |
?> | |
</p> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment