Hi,
Try this:
<?php
class numtowords{
public $string;
public $number;
private $fp;
private $linefeed;
private $data;
function __construct($string){
$this->string=$string;//which holds the file contents
echo $this->string;
$this->linefeed=explode(",",$this->string);
print_r($this->linefeed);
$this->loopData();
}
function loopData(){
foreach($this->linefeed as $key=>$value){
$split=explode(".",$value);
$rspart="Rupees ".$this->numToWords($split[0]);
$pspart="";
if(count($split)==2){
$pspart=($split[1]!="")?" and ".$this->numToWords($split[1])." Paise":"";
}
$this->data[]=$rspart.$pspart;
}
}
function numToWords($number){
if (($number < 0) || ($number > 999999999)){
return "$number out of script range";
}
$lakhs = floor($number / 100000); /* lakhs (giga) */
$number -= $lakhs * 100000;
$thousands = floor($number / 1000); /* Thousands (kilo) */
$number -= $thousands * 1000;
$hundreds = floor($number / 100); /* Hundreds (hecto) */
$number -= $hundreds * 100;
$tens = floor($number / 10); /* Tens (deca) */
$ones = $number % 10; /* Ones */
$res = "";
//echo "<hr>".$lakhs;
if ($lakhs){
$res .= $this->numToWords($lakhs) ;
$res.=($lakhs>10)?" Lakhs":" Lakh";
}
if($thousands){
$res .= (empty($res) ? "" : " ") .
$this->numToWords($thousands) . " Thousand";
}
if ($hundreds){
$res .= (empty($res) ? "" : " ") .
$this->numToWords($hundreds) . " Hundred";
}
$arr_ones = array("", "One", "Two", "Three", "Four", "Five", "Six",
"Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen",
"Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eightteen",
"Nineteen");
$arr_tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty",
"Seventy", "Eigthy", "Ninety");
if ($tens || $ones){
if (!empty($res)){
$res .= " and ";
}
if ($tens < 2){
$res .= $arr_ones[$tens * 10 + $ones];
}
else{
$res .= $arr_tens[$tens];
if ($ones){
$res .= "-" . $arr_ones[$ones];
}
}
}
if (empty($res)){
$res = "zero";
}
return $res;
}
function flushData(){
print_r($this->data[0]);
}
}
$string="10000000";
$num2word=new numtowords($string);
$num2word->flushData();
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111:





by: absxPosted on 2009-05-20 at 01:36:57ID: 24429566
Hi,
I'm afraid none of the teach-yourself-sanskrit guides I found with Google gives any idea on how exactly are numerals expressed in Indian. If you could describe the format, maybe even us non-Indian speakers could provide some help?