Im trying to convert numbers to words (without using any functions, the range is between -1000 to 1000, the code should be able to print the numbers in words, but Im stuck and dont know where to go from here, can you please assist me, below is the code so far
[php]<?php
$units = array(“zero”, “one”, “two”, “three”, “four”, “five”,
“six”, “seven”, “eight”, “nine”, “ten”, “eleven”,
“twelve”, “thirteen”, “forteen”, “fifteen”,
“sixteen”, “seventeen”, “eighteen”, “nineteen”);
$tens = array(“twenty”, “thirty”, “forty”, “fifty”, “sixty”,
“seventy”, “eighty”, “ninety”);
$hundreds = array(“hundred”);
$thousand = array(“thousand”);
$number = -11;
$signedMinus = "Minus ";
$output = “”;
$n = ($number%10); // ones
$tn = ($number/10); // tens
$hn = ($number/100); // hundreds
$thn = ($number/1000); // thousands
$convertor = “”;
if ($number<0) {
$output .=$signedMinus;
$number = abs($number);
}
else
{
$output .="";
}
if (is_numeric($number)) { // error trapping
if ($number <=1000) { // within range
$output .=$units[$number];
}
}
echo $output;
?>[/php]