Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php number to word

# Use the NumberFormatter class that are in php

$f = new NumberFormatter("en", NumberFormatter::SPELLOUT);
echo $f->format(1432);
Comment

php number to words

//This if function to convert numbers to Indian Currency

function getIndianCurrency(float $number)
{
    $decimal = round($number - ($no = floor($number)), 2) * 100;
    $hundred = null;
    $digits_length = strlen($no);
    $i = 0;
    $str = array();
    $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');
    while( $i < $digits_length ) {
        $divider = ($i == 2) ? 10 : 100;
        $number = floor($no % $divider);
        $no = floor($no / $divider);
        $i += $divider == 10 ? 1 : 2;
        if ($number) {
            $plural = (($counter = count($str)) && $number > 9) ? 's' : null;
            $hundred = ($counter == 1 && $str[0]) ? ' and ' : null;
            $str [] = ($number < 21) ? $words[$number].' '. $digits[$counter]. $plural.' '.$hundred:$words[floor($number / 10) * 10].' '.$words[$number % 10]. ' '.$digits[$counter].$plural.' '.$hundred;
        } else $str[] = null;
    }
    $Rupees = implode('', array_reverse($str));
    $paise = ($decimal > 0) ? "." . ($words[$decimal / 10] . " " . $words[$decimal % 10]) . ' Paise' : '';
    return ($Rupees ? $Rupees . 'Rupees ' : '') . $paise;
}
Comment

how to convert amount in words in php

How to convert amount to words in php
Comment

PREVIOUS NEXT
Code Example
Php :: Creating default object from empty value 
Php :: valid image extensions in php 
Php :: root composer.json requires php ^7.3 but your php version (8.0.3) does not satisfy that requirement. 
Php :: import local js file laravel 
Php :: carbon greater than 
Php :: php array_intersect 
Php :: php logout 
Php :: laravel migration integer 
Php :: woocommerce after order been placed hook 
Php :: laravel activity log 
Php :: convert array into , separated string in php 
Php :: min function in php 
Php :: laravel blade conditional class 
Php :: insert multiple rows laravel 
Php :: php http errorcode 
Php :: laravel check if email is real 
Php :: filesize in php 
Php :: php currency formator 
Php :: update wordpress query 
Php :: laravel parent child relationship in same table 
Php :: __invoke in laravel 
Php :: How do I get current taxonomy "term id" on wordpress? 
Php :: slugify text in php 
Php :: laravel elequent query 
Php :: wp add menu page and subpage 
Php :: how to send mail in laravel 
Php :: The media must not be greater than 12288 kilobytes in laravel 
Php :: why we use .htaccess file in php 
Php :: php call constant in class 
Php :: Create a table with PHP in html 
ADD CONTENT
Topic
Content
Source link
Name
8+1 =