PHP code example of hikuroshi / terbilang-number-to-word

1. Go to this page and download the library: Download hikuroshi/terbilang-number-to-word 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/ */

    

hikuroshi / terbilang-number-to-word example snippets


use Hikuroshi\Terbilang\Terbilang;

// Convert number to words
echo Terbilang::terbilang(24434);
// Outputs "twenty four thousand four hundred thirty four"

// Convert number to words with digit separation
echo Terbilang::terbilang(24434, true);
// Outputs "two four four three four"

use Hikuroshi\Terbilang\Terbilang;

// Convert number to words
echo Terbilang::terbilang(24434);
// Outputs "twenty four thousand four hundred thirty four"

use Hikuroshi\Terbilang\Terbilang;

// Convert number with default simplification
echo Terbilang::terbilang(1111)->simply();
// Outputs "a thousand a hundred eleven"

// Convert number with specified simplification
echo Terbilang::terbilang(1111)->simply(['hundred']);
// Outputs "one thousand a hundred eleven"

use Hikuroshi\Terbilang\Terbilang;

// Convert number with custom separator
echo Terbilang::terbilang(24434)->separator(' >//< ');
// Outputs "twenty >//< four >//< thousand >//< four >//< hundred >//< thirty >//< four"

use Hikuroshi\Terbilang\Terbilang;

// Convert number with camel case style
echo Terbilang::terbilang(24434)->caseStyle('camel');
// Outputs "twentyFourThousandFourHundredThirtyFour"

use Hikuroshi\Terbilang\Terbilang;

// Convert number to words with Indonesian language
echo Terbilang::terbilang(24434)->lang('id');
// Outputs "dua puluh empat ribu empat ratus tiga puluh empat"

use Hikuroshi\Terbilang\Terbilang;

// Load custom language rules from an array
$customLanguageRules = [
    "units" => ["rei", "ichi", "ni", "san", "yon", "go", "roku", "nana", "hachi", "kyuu"]
];

echo Terbilang::loadLang($customLanguageRules)->terbilang(24434);
// Outputs "twenty yon thousand yon hundred thirty yon"

// Load custom language rules from a JSON file
echo Terbilang::loadLang('/path/to/custom_language_rules.json')->terbilang(24434);

$customLanguageRules = [
    "units" => ["rei", "ichi", "ni", "san", "yon", "go", "roku", "nana", "hachi", "kyuu"],
    "numberingSystem" => "japanese"
];