@ 2017-12-12T12:03:21Z <?php
function displaywords($number){
$words = array('0' => '', '1' => 'one', '2' => 'two',
'3' => 'three', '4' => 'four', '5' => 'five', '6' => 'six',
'7' => 'seven', '8' => 'eight', '9' => 'nine',
'10' => 'ten', '11' => 'eleven', '12' => 'twelve',
'13' => 'thirteen', '14' => 'fourteen',
'15' => 'fifteen', '16' => 'sixteen', '17' => 'seventeen',
'18' => 'eighteen', '19' =>'nineteen', '20' => 'twenty',
'30' => 'thirty', '40' => 'forty', '50' => 'fifty',
'60' => 'sixty', '70' => 'seventy',
'80' => 'eighty', '90' => 'ninety');
$digits = array('', '', 'hundred', 'thousand', 'lakh', 'crore');
$number = explode(".", $number);
$result = array("","");
$j =0;
foreach($number as $val){
// loop each part of number, right and left of dot
for($i=0;$i<strlen($val);$i++){
// look at each part of the number separately [1] [5] [4] [2] and [5] [8]
$numberpart = str_pad($val[$i], strlen($val)-$i, "0", STR_PAD_RIGHT); // make 1 => 1000, 5 => 500, 4 => 40 etc.
if($numberpart <= 20){
$numberpart = 1*substr($val, $i,2);
$i++;
$result[$j] .= $words[$numberpart] ." ";
}else{
//echo $numberpart . "<br>\n"; //debug
if($numberpart > 90){ // more than 90 and it needs a $digit.
$result[$j] .= $words[$val[$i]] . " " . $digits[strlen($numberpart)-1] . " ";
}else if($numberpart != 0){ // don't print zero
$result[$j] .= $words[str_pad($val[$i], strlen($val)-$i, "0", STR_PAD_RIGHT)] ." ";
}
}
}
$j++;
}
if(trim($result[0]) != "") echo $result[0] . "Rupees ";
if($result[1] != "") echo $result[1] . "Paise";
echo " Only";
}
$ins=1516.00;
echo displaywords($ins);
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for 5.6.0 - 5.6.40 , 7.0.0 - 7.0.33 , 7.1.0 - 7.1.33 , 7.2.0 - 7.2.34 , 7.3.0 - 7.3.33 , 7.4.0 - 7.4.33 , 8.0.0 - 8.0.30 , 8.1.0 - 8.1.28 , 8.2.0 - 8.2.18 , 8.3.0 - 8.3.4 , 8.3.6 one thousand five hundred sixteen Rupees Only Output for 8.3.5 Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
one thousand five hundred sixteen Rupees Only preferences:dark mode live preview
252.61 ms | 402 KiB | 300 Q