Current File : /home/inlingua/www/noida/icentex/admin_fd/wordsClass.php
<?php
class intToWord
{
function 
		getAmountInWords($input)
		{
				 $arr_name = array('1'=>'','','hundreds','thousand','lacs');
				 $arr_num = array('1'=>'One','Two','Three','Four','Five','Six','Seven','Eight','Nine','Ten','Eleven','Twelve','Thirteen','Fourteen','Fifteen','Sixteen','Seventeen', 'Eighteen','Nineteen');
				 $arr_one =array('1'=>'One','Two','Three','Four','Five','Six','Seven','Eight','Nine');
				 $arr_tens =array('2'=>'Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety');
				 
				 //$this->number = number_format($input,2);
				 list($this->pounds,$this->pence) = explode('.',$input);
				 $input=$this->pounds;
			 if(is_numeric($input))
			  { 
  				if(strlen($input)>8)
				 //$moreDate = "input is more then 99999999";
				 $moreDate = "";
				 $inputnew = $input;
				 $inputnew;
				 $arr_int  = str_split($inputnew);
				 $count  = count($arr_int);
				$ones =  substr($input,-2);
				if($count > 2)
				 $hunderads =  substr($input,-3,1);
				if($count > 3){
				if($count==4){
				$input;
				  $thousands =  substr($input,-4,1);
				 }
				else{
				  $thousands =  substr($input,-5,2);
				 }
				}
				if($count > 5){
				if($count==6)
				 $lacs =  substr($input,-6,1);
				else
				 $lacs =  substr($input,-7,2);
				}
				if($count > 7){
				if($count==8)
				 $cror =  substr($input,-8,1);
				else
				 $cror =  substr($input,-9,2);
				}
				//************************************************************************************************************************************
				if($cror<=19)
				{
				$cror = $arr_num[$cror];
				}	
				if($cror>19)
				{
				$onepart=substr($cror,0,1);
				$secoundpart=substr($cror,1,1);
				$cror = $arr_tens[$onepart]." ".$arr_one[$secoundpart];
				}
				//echo $cror."test";
				if($lacs<=19)
				{
				$lacs = $arr_num[$lacs];
				}
				$lacs;
				if($lacs>19)
				{
				$onepart=substr($lacs,0,1);
				$secoundpart=substr($lacs,1,1);
				$lacs = $arr_tens[$onepart]." ".$arr_one[$secoundpart];
				}

				if($thousands<=19)
				{
				$thousands = $arr_num[$thousands];
				}
				if($thousands>19)
				{
				$onepart=substr($thousands,0,1);
				$secoundpart=substr($thousands,1,1);
				$thousands = $arr_tens[$onepart]." ".$arr_one[$secoundpart];
				}
				
				if($hunderads<=19)
				{
				if($hunderads!=10)
				$hunderads = str_replace("0","", $hunderads);
				$hunderads = $arr_num[$hunderads];
				}
				if($hunderads>19)
				{
				$onepart=substr($hunderads,0,1);
				$secoundpart=substr($hunderads,1,1);
				$hunderads = $arr_tens[$onepart]." ".$arr_one[$secoundpart];
				}
				if($ones<=19)
				{
				if($ones!=10)
				$ones = str_replace("0","", $ones);
				$ones = $arr_num[$ones];
				}
				if($ones>19)
				{
				$onepart=substr($ones,0,1);
				$secoundpart=substr($ones,1,1);
				if($onepart!=0)
				$ones = $arr_tens[$onepart]." ".$arr_one[$secoundpart];
				else
				$ones = $arr_tens[$secoundpart];
				}
				//**********************************************************************************************************************
				if($cror!="")
				$Cror = "Crores";
				if($lacs!="")
				$lakh = "Lakh";
				if($thousands!="")
				$thoussn = "Thousand";
				if($hunderads!="")
				$hun = "hundred";
				$outPut = $cror." ".$Cror." ".$lacs." ".$lakh." ".$thousands." ".$thoussn." ".$hunderads." ".$hun." ".$ones;
				/*return $outPut."<br>".$moreDate;*/
				if($this->pence>0)
				{
				 $outPut .= ", $this->pence Paise ";
				}
				
				return "Indian Rupees ".$outPut." Only";
			 }
			 else 
			 {
			 	$outPut = "INPUT IS NOT NUMERIC";
			 	return $outPut;
			 }
		}
}

?>