$orderOfMag = array('Hundred', 'Thousand,', 'Million,', 'Billion,', 'Trillion,');
$smallNumbers = array('Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine',
'Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen');
$decades = array('', '', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety');

function NumberToEnglish($num, $count = 0){
   global $orderOfMag, $smallNumbers, $decades;
   $isLast = true;
   $str = '';

   if ($num < 0){
      $str = 'Negative ';
      $num = abs($num);
   }

   (int) $thisPart = substr((string) $num, -3);

   if (strlen((string) $num) > 3){
      
      $str .= NumberToEnglish((int) substr((string) $num, 0, strlen((string) $num) - 3), $count + 1);
      $isLast = false;
   }

   
   if (($count == 0 || $isLast) && ($str == '' || $str == 'Negative '))
      
      $and = '';
   else
      $and = ' and ';

   if ($thisPart > 99){
      
      $str .= ($isLast? '' : ' ') . ;

      if(($thisPart %= 100) == 0){
         
         $str .= ;
         return $str;
      }
      $and = ' and ';  
   }

   if ($thisPart >= 20){
      
      $str .= ;
      $and = ' '; 
      if(($thisPart %= 10) == 0)
         return $str . ($count != 0?  : '');
   }

   if ($thisPart < 20 && $thisPart > 0)
      
      return $str .  . ($count != 0? $orderOfMag[$count] : '');
   elseif ($thisPart == 0 && strlen($thisPart) == 1)
      
      return $str . ;
}