Posted By

Scooter on 02/28/09


Tagged


Versions (?)

Phonetic Alphabet


 / Published in: PHP
 

URL: http://reusablecode.blogspot.com/2009/02/phonetic-alphabet.html

Converts individual characters to their corresponding pronunciation in the internationally-standardized phonetic alphabet.

  1. <?php
  2. /*
  3.   Copyright (c) 2009, reusablecode.blogspot.com; some rights reserved.
  4.  
  5.   This work is licensed under the Creative Commons Attribution License. To view
  6.   a copy of this license, visit http://creativecommons.org/licenses/by/3.0/ or
  7.   send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California
  8.   94305, USA.
  9.   */
  10.  
  11. // Convert letters and numbers to corresponding NATO phonetic alphabet code words.
  12. function phonetic($char)
  13. {
  14. $nato = array(
  15. "a" => "alfa",
  16. "b" => "bravo",
  17. "c" => "charlie",
  18. "d" => "delta",
  19. "e" => "echo",
  20. "f" => "foxtrot",
  21. "g" => "golf",
  22. "h" => "hotel",
  23. "i" => "india",
  24. "j" => "juliett",
  25. "k" => "kilo",
  26. "l" => "lima",
  27. "m" => "mike",
  28. "n" => "november",
  29. "o" => "oscar",
  30. "p" => "papa",
  31. "q" => "quebec",
  32. "r" => "romeo",
  33. "s" => "sierra",
  34. "t" => "tango",
  35. "u" => "uniform",
  36. "v" => "victor",
  37. "w" => "whisky",
  38. "x" => "x-ray",
  39. "y" => "yankee",
  40. "z" => "zulu",
  41. "0" => "zero",
  42. "1" => "one",
  43. "2" => "two",
  44. "3" => "three",
  45. "4" => "four",
  46. "5" => "five",
  47. "6" => "six",
  48. "7" => "seven",
  49. "8" => "eight",
  50. "9" => "niner"
  51. );
  52.  
  53. return $nato[strtolower($char)];
  54. }
  55. ?>

Report this snippet  

You need to login to post a comment.