Created
July 30, 2017 09:59
-
-
Save HoangPV/73953f67d0bb2dd325de1b14285cca62 to your computer and use it in GitHub Desktop.
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 | |
/** | |
* You'll have to translate a string to Pilot's alphabet (NATO phonetic alphabet) wiki. | |
* | |
* @author Phan Vu Hoang <[email protected]> | |
*/ | |
function to_nato($words) { | |
$lib['a']="Alpha"; | |
$lib['b']="Bravo"; | |
$lib['c']="Charlie"; | |
$lib['d']="Delta"; | |
$lib['e']="Echo"; | |
$lib['f']="Foxtrot"; | |
$lib['g']="Golf"; | |
$lib['h']="Hotel"; | |
$lib['i']="India"; | |
$lib['j']="Juliet"; | |
$lib['k']="Kilo"; | |
$lib['l']="Lima"; | |
$lib['m']="Mike"; | |
$lib['n']="November"; | |
$lib['o']="Oscar"; | |
$lib['p']="Papa"; | |
$lib['q']="Quebec"; | |
$lib['r']="Romeo"; | |
$lib['s']="Sierra"; | |
$lib['t']="Tango"; | |
$lib['u']="Uniform"; | |
$lib['v']="Victor"; | |
$lib['w']="Whiskey"; | |
$lib['x']="X-Ray"; | |
$lib['y']="Yankee"; | |
$lib['z']="Zulu"; | |
$lib['0']="Zero"; | |
$lib['1']="One"; | |
$lib['2']="Two"; | |
$lib['3']="Three"; | |
$lib['4']="Four"; | |
$lib['5']="Five"; | |
$lib['6']="Six"; | |
$lib['7']="Seven"; | |
$lib['8']="Eight"; | |
$lib['9']="Nine"; | |
$lib['-']="Dash"; | |
$nato=array(); | |
$words = strtolower($words); | |
for ($i=0; $i < strlen($words); $i++) { | |
$letter = substr($words, $i, 1); | |
foreach ($lib as $key => $value) { | |
if($letter === $key ) { | |
$nato[] = $value; | |
} | |
} | |
} | |
return implode(" ",$nato); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment