Skip to content

Instantly share code, notes, and snippets.

@niczak
Created January 8, 2014 20:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save niczak/8324162 to your computer and use it in GitHub Desktop.
Save niczak/8324162 to your computer and use it in GitHub Desktop.
Convert numbers to words.
<?php
function numToStr($val) {
$aLookup = array(
0 => "zero",
1 => "one",
2 => "two",
3 => "three",
4 => "four",
5 => "five",
6 => "six",
7 => "seven",
8 => "eight",
9 => "nine");
$aVal = str_split($val);
$return = '';
foreach($aVal as $tmp) {
if(array_key_exists($tmp, $aLookup))
$return .= $aLookup[$tmp]." ";
else
$return .= $tmp." ";
}
echo $return;
}
numToStr("3735711A2387480E95AC924588038B49");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment