/* Determine if the number is negative.
If so, remember that fact and chop off the "-". */
if ($number < 0) {
$negative_flag = 'Negative ';
$number = substr($number, 1);
}

/* Take only the integer part of the number for the
calculation of the integer part verbage */
if ($number = strtok($number,'.')) {
/* Iterate through $number breaking off each three digit pair from right to left
corresponding to each of the $classifications. */
for ($i = 0; !empty($number); $i++, $number = substr($number, 0, -3)) {
/* if the three number triplet isn't all zeros */
if (($word = substr($number, -3)) != 0) {
/* add the $word to $final with a comma and a space */
$final = HandleThreeDigit($word).' '.$classifications[$i].", $final";
}
}

/* If we marked the number as negative in the beginning, make the
verbage reflect that by prepending Negative.
Also, strip out trailing ", " */
$final = $negative_flag.substr($final,0,-2);
} else {
/* If $number is empty, then our integer part is zero.
Make the verbage reflect that. */
$final = 'Zero';
}

/* Hand the decimal number off to get its verbage.
Append it to $final.
Return the verbage to the calling program. */
return($final .= HandleDecimal(strtok('.')));
}

$category_verbage = $categories[strlen($number)];
/* if the value of what's after the decimal place is one, then
we need to chop the "s" off the end of the $category_verbage
to make it singular */
if ($number == 1) {
$category_verbage = substr($category_verbage, 0, -1);
}

return(' and '.num2word($number)." $category_verbage");
}
?>

Comments or questions?
PX is running PHP 5.2.17
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.