I just hacked together a little somethin somethin that can tackle this. the str_split() was from some user-added php documentation but the rest is mine.
<?php
# input a number in numeric format
# and read it out in english letters
$dollars = 'dollars';
$and = 'and';
$cents = 'cents';
$numbers = array (
1 => 'one',
2 => 'two',
3 => 'three',
4 => 'four',
5 => 'five',
6 => 'six',
7 => 'seven',
8 => 'eight',
9 => 'nine',
10 => 'ten',
11 => 'eleven',
12 => 'twelve',
13 => 'thirteen',
14 => 'fourteen',
15 => 'fifteen',
16 => 'sixteen',
17 => 'seventeen',
18 => 'eightteen',
19 => 'nineteen',
20 => 'twenty',
30 => 'thirty',
40 => 'forty',
50 => 'fifty',
100 => 'hundred',
1000 => 'thousand',
1000000 => 'million'
);
$places = array (
2 => 'thousand',
3 => 'million',
4 => 'billion',
5 => 'trillion',
);
function str_split($str,$num = '1') {
if($num < 1) return FALSE;
$arr = array();
for ($j = 0; $j < strlen($str); $j= $j+$num) {
$arr[] = substr($str,$j,$num);
}
return $arr;
}
function tens($n2arr) {
global $numbers;
if ($n2arr[1] < 2 && $n2arr[1] > 0) {
$n = $n2arr[1].$n2arr[2];
$word .= $numbers[$n];
} else if ($n2arr[1] > 1) {
$word .= ($numbers[$n2arr[1]*10]
? $numbers[$n2arr[1]*10]
: $numbers[$n2arr[1]].'ty').' '.$numbers[$n2arr[2]];
} else {
$word .= " ".$numbers[$n2arr[2]];
}
return $word;
}
function num2word($number) {
global $numbers,$places;
global $dollars,$and,$cents;
$narr = array_reverse(str_split(strrev($number),3));
$nacount = count($narr);
if ($narr[$nacount-1][2] == '.') {
$placeshift = 1;
} else {
$placeshift = 0;
}
for ($i=0;$i<$nacount;$i++) {
$n2arr = array_reverse(str_split(str_pad($narr[$i],3,'0')));
if ($n2arr[0] == '.') {
$word .= " $dollars $and ".tens($n2arr)." $cents";
return $word;
} else if ($n2arr[0] > 0) {
$word .= $numbers[$n2arr[0]].' hundred ';
}
$word .= tens($n2arr);
if ($places[$nacount-$i-$placeshift]) {
$word .= " ".$places[$nacount-$i-$placeshift]." ";
}
}
return $word;
}
$number = $_GET[number] ? $_GET[number] : 543016103;
$number = str_replace(',','',$number);
echo "WORD: ".num2word($number)."<BR>";
?>