Created
June 25, 2017 18:57
-
-
Save sebsel/c2b014058ade928bc1f6eae64f34561f to your computer and use it in GitHub Desktop.
CLI for naming things
This file contains hidden or 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 | |
| echo 'What pattern of consonants and vowels? '; | |
| echo '(use "C" and "V" like CVC or CVCV)'.PHP_EOL; | |
| $pattern = trim(fgets(STDIN), PHP_EOL); | |
| $a = [ | |
| 'a','e','i','o','u', | |
| ]; | |
| $b = [ | |
| 'b','c','d','f','g','h', | |
| 'j','k','l','m','n','p', | |
| 'q','r','s','t','v','w', | |
| 'x','y','z' | |
| ]; | |
| $name = ''; | |
| foreach(str_split(strtolower($pattern)) as $ch) { | |
| if($ch == 'c') $name .= $b[array_rand($b)]; | |
| elseif($ch == 'v') $name .= $a[array_rand($a)]; | |
| else die('I said a pattern of "C" or "V"!'.PHP_EOL); | |
| } | |
| usleep(400000); | |
| echo 'Great! '; | |
| usleep(400000); | |
| echo 'Wait. '; | |
| usleep(600000); | |
| echo 'Let me think...'.PHP_EOL; | |
| sleep(2); | |
| echo 'Ready?'.PHP_EOL; | |
| sleep(1); | |
| echo '3'.PHP_EOL; | |
| sleep(1); | |
| echo '2'.PHP_EOL; | |
| sleep(1); | |
| echo '1'.PHP_EOL.PHP_EOL; | |
| sleep(1); | |
| echo $name.PHP_EOL.PHP_EOL; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment