Last active
February 18, 2016 12:28
-
-
Save parsingphase/7fa3c42642c10d7129f0 to your computer and use it in GitHub Desktop.
Accidental Star Wars Name Generator
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 | |
function generateJediName($words = 2) | |
{ | |
$vowels = ['a', 'e', 'i', 'o', 'u']; | |
$parts = []; | |
for ($i = 0; $i < $words; $i++) { | |
$parts[$i] = chr(rand(65, 90)); // upper case | |
$wordLength = rand(4, 7); | |
for ($j = 0; $j < ($wordLength - 1); $j++) { | |
if ($j % 2) { | |
$parts[$i] .= chr(rand(97, 122)); //lower case, could exclude vowels | |
} else { | |
$parts[$i] .= $vowels[rand(0, count($vowels) - 1)]; // random lc vowel | |
} | |
} | |
} | |
return join(' ', $parts); | |
} | |
echo generateJediName()."\n\n"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment