<?
function NumbersToText($num){

  
/* Set up hash */
  
$numtext["1"] = "One";
  
$numtext["2"] = "Two";
  
$numtext["3"] = "Three";
  
$numtext["4"] = "Four";
  
$numtext["5"] = "Five";
  
$numtext["6"] = "Six";
  
$numtext["7"] = "Seven";
  
$numtext["8"] = "Eight";
  
$numtext["9"] = "Nine";
  
$numtext["10"] = "Ten";
  
$numtext["11"] = "Eleven";
  
$numtext["12"] = "Twelve";
  
$numtext["13"] = "Thirteen";
  
$numtext["14"] = "Fourteen";
  
$numtext["15"] = "Fifteen";
  
$numtext["16"] = "Sixteen";
  
$numtext["17"] = "Seventeen";
  
$numtext["18"] = "Eightteen";
  
$numtext["19"] = "Nineteen";
  
$numtext["20"] = "Twenty";
  
$numtext["30"] = "Thirty";
  
$numtext["40"] = "Fourty";
  
$numtext["50"] = "Fifty";
  
$numtext["60"] = "Sixty";
  
$numtext["70"] = "Seventy";
  
$numtext["80"] = "Eighty";
  
$numtext["90"] = "Ninty";

  
$num sprintf ("%015.2f"$num);

  
/* indexed from the back of the string to make it easier to change */
  
$hunbillion  substr($num, -151);
  
$billion     substr($num, -142);
  
$hunmillion  substr($num, -121);
  
$million     substr($num, -112);
  
$hunthousand substr($num, -91);
  
$thousand    substr($num, -82);
  
$hundred     substr($num, -61);
  
$tens        substr($num, -52);
  
$dec         substr($num, -22);

  
$number "";
  
/* BILLIONS */
  
if($hunbillion != || $billion != 0){
    if(
$hunbillion != 0){
      
$number .= $numtext[$hunbillion] . " Hundred";
    }

    if(
$billion != 0){
      
$number .= " " GetTens($billion);
    }
    
$number .= " Billion";
  }

  
/* MILLIONS */
  
if($hunmillion != || $million != 0){
    if(
$hunmillion != 0){
      
$number .= " " $numtext[$hunmillion] . " Hundred";
    }

    if(
$million != 0){
      
$number .= " " GetTens($million);
    }
    
$number .= " Million";
  }


  
/* THOUSANDS */
  
if($hunthousand != || $thousand != 0){
    if(
$hunthousand != 0){
      
$number .= " "$numtext[$hunthousand] . " Hundred";
    }

    if(
$thousand != 0){
      
$number .= " " GetTens($thousand);
    }
    
$number .= " Thousand";
  }

  
/* HUNDREDS */
  
if($hundred != || $tens != 0){
    if(
$hundreds != 0){
      
$number .= " "$numtext[$hundred] . " Hundred";
    }

    if(
$tens != 0){
      
$number .= " " GetTens($tens);
    }
    
$number .= "";
  }


  
/* DECIMAL */
  
if($dec != 0){
    
$number .= " And $dec/100";
  }

  return 
$number;
}



function 
GetTens($num){

  
$numtext["1"] = "One";
  
$numtext["2"] = "Two";
  
$numtext["3"] = "Three";
  
$numtext["4"] = "Four";
  
$numtext["5"] = "Five";
  
$numtext["6"] = "Six";
  
$numtext["7"] = "Seven";
  
$numtext["8"] = "Eight";
  
$numtext["9"] = "Nine";
  
$numtext["10"] = "Ten";
  
$numtext["11"] = "Eleven";
  
$numtext["12"] = "Twelve";
  
$numtext["13"] = "Thirteen";
  
$numtext["14"] = "Fourteen";
  
$numtext["15"] = "Fifteen";
  
$numtext["16"] = "Sixteen";
  
$numtext["17"] = "Seventeen";
  
$numtext["18"] = "Eightteen";
  
$numtext["19"] = "Nineteen";
  
$numtext["20"] = "Twenty";
  
$numtext["30"] = "Thirty";
  
$numtext["40"] = "Fourty";
  
$numtext["50"] = "Fifty";
  
$numtext["60"] = "Sixty";
  
$numtext["70"] = "Seventy";
  
$numtext["80"] = "Eighty";
  
$numtext["90"] = "Ninty";

  if(
$num <= 20){
    echo 
"madeit: $num ";
    if(
$num <= 9){
       
$num substr($num11);
    }

    
$number $numtext[$num];

  }else if(
$num >= 100){
    
$number "Error";
  }else{
    
$tens substr($num01);
    
$ones substr($num11);
    
$tens $tens *  10;
    
$number $numtext[$tens] ."-"strtolower($numtext[$ones]);
  }



  return 
$number;
}

?>