PHP code example of lla / numbers_words

1. Go to this page and download the library: Download lla/numbers_words library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

lla / numbers_words example snippets


composer install ncrypthic/numbers

use \LLA\Numbers\Words;

use \LLA\Numbers\Words;

$num   = 12340000000;
$words = Words::fromWords($num,"en_GB");
echo "Num $num in British English is '<b>$words</b>'<p>\n";

use \LLA\Numbers\Words;

function num2word($num, $fract = 0) {

    $num = sprintf("%.".$fract."f", $num);
    $fnum = explode('.', $num);

    $ret =  Words::fromNumber($fnum[0],"id");
    if(!$fract) return $ret;

    $ret .=  ' koma '; // point in english
    $ret .= Words::fromNumber($fnum[1],"id");

    return $ret;
}

use \LLA\Numbers\Words;
use \LLA\Numbers\Words\Locale\en\GB;

$obj = new GB();
$convert_fraction = false;
print $obj->toCurrencyWords('GBP', '31', '01', $convert_fraction) . "\n";