?
Current Path : /home1/savoy/public_html/savoyglobal.net/sgms/application/views/Accounting/ |
Linux gator3171.hostgator.com 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 |
Current File : /home1/savoy/public_html/savoyglobal.net/sgms/application/views/Accounting/number2word.php |
<?php function convert_number($number) { if (($number < 0) || ($number > 999999999)) { return ''; } $Gn = floor($number / 1000000); /* Millions (giga) */ $number -= $Gn * 1000000; $kn = floor($number / 1000); /* Thousands (kilo) */ $number -= $kn * 1000; $Hn = floor($number / 100); /* Hundreds (hecto) */ $number -= $Hn * 100; $Dn = floor($number / 10); /* Tens (deca) */ $n = $number % 10; /* Ones */ $res = ""; if ($Gn) { $res .= convert_number($Gn) . " Million"; } if ($kn) { $res .= (empty($res) ? "" : " ") . convert_number($kn) . " Thousand"; } if ($Hn) { $res .= (empty($res) ? "" : " ") . convert_number($Hn) . " Hundred"; } $ones = array("", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten", "Eleven", "Twelve", "Thirteen", "Fourteen", "Fifteen", "Sixteen", "Seventeen", "Eighteen", "Nineteen"); $tens = array("", "", "Twenty", "Thirty", "Fourty", "Fifty", "Sixty", "Seventy", "Eighty", "Ninety"); if ($Dn || $n) { if (!empty($res)) { $res .= " and "; } if ($Dn < 2) { $res .= $ones[$Dn * 10 + $n]; } else { $res .= $tens[$Dn]; if ($n) { $res .= " " . $ones[$n]; } } } if (empty($res)) { $res = "zero"; } return $res; } ?>