PHP code example of ibrahim-bougaoua / numbertowords
1. Go to this page and download the library: Download ibrahim-bougaoua/numbertowords 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/ */
ibrahim-bougaoua / numbertowords example snippets
return [
// default lang
'lang' => 'en',
'words' => [
// Arabic words
'units_ar' => ['', 'واحد', 'اثنان', 'ثلاثة', 'أربعة', 'خمسة', 'ستة', 'سبعة', 'ثمانية', 'تسعة'],
'teens_ar' => ['عشرة', 'أحد عشر', 'اثنا عشر', 'ثلاثة عشر', 'أربعة عشر', 'خمسة عشر', 'ستة عشر', 'سبعة عشر', 'ثمانية عشر', 'تسعة عشر'],
'tens_ar' => ['', 'عشرة', 'عشرون', 'ثلاثون', 'أربعون', 'خمسون', 'ستون', 'سبعون', 'ثمانون', 'تسعون'],
'thousands_ar' => ['', 'ألف', 'مليون', 'مليار', 'بليون'],
'zero_ar' => 'صفر',
'negative_ar' => 'سالب ',
'hundred_ar' => ' مائة ',
'and_ar' => ' و ',
'cents_ar' => ' قروش',
// English words
'units_en' => ['', 'One', 'Two', 'Three', 'Four', 'Five', 'Six', 'Seven', 'Eight', 'Nine'],
'teens_en' => ['Ten', 'Eleven', 'Twelve', 'Thirteen', 'Fourteen', 'Fifteen', 'Sixteen', 'Seventeen', 'Eighteen', 'Nineteen'],
'tens_en' => ['', 'Ten', 'Twenty', 'Thirty', 'Forty', 'Fifty', 'Sixty', 'Seventy', 'Eighty', 'Ninety'],
'thousands_en' => ['', 'Thousand', 'Million', 'Billion', 'Trillion'],
'zero_en' => 'Zero',
'negative_en' => 'Negative ',
'hundred_en' => ' Hundred ',
'and_en' => ' and ',
'cents_en' => ' Cents',
// French words
'units_fr' => ['', 'Un', 'Deux', 'Trois', 'Quatre', 'Cinq', 'Six', 'Sept', 'Huit', 'Neuf'],
'teens_fr' => ['Dix', 'Onze', 'Douze', 'Treize', 'Quatorze', 'Quinze', 'Seize', 'Dix-sept', 'Dix-huit', 'Dix-neuf'],
'tens_fr' => ['', 'Dix', 'Vingt', 'Trente', 'Quarante', 'Cinquante', 'Soixante', 'Soixante-dix', 'Quatre-vingts', 'Quatre-vingt-dix'],
'thousands_fr' => ['', 'Mille', 'Million', 'Milliard', 'Billion'],
'zero_fr' => 'Zéro',
'negative_fr' => 'Négatif ',
'hundred_fr' => ' Cent ',
'and_fr' => ' et ',
'cents_fr' => ' Centimes',
// Spanish words
'units_es' => ['', 'Uno', 'Dos', 'Tres', 'Cuatro', 'Cinco', 'Seis', 'Siete', 'Ocho', 'Nueve'],
'teens_es' => ['Diez', 'Once', 'Doce', 'Trece', 'Catorce', 'Quince', 'Dieciséis', 'Diecisiete', 'Dieciocho', 'Diecinueve'],
'tens_es' => ['', 'Diez', 'Veinte', 'Treinta', 'Cuarenta', 'Cincuenta', 'Sesenta', 'Setenta', 'Ochenta', 'Noventa'],
'thousands_es' => ['', 'Mil', 'Millón', 'Mil Millones', 'Billón'],
'zero_es' => 'Cero',
'negative_es' => 'Negativo ',
'hundred_es' => ' Cien ',
'and_es' => ' y ',
'cents_es' => ' Centavos',
// German words
'units_de' => ['', 'Eins', 'Zwei', 'Drei', 'Vier', 'Fünf', 'Sechs', 'Sieben', 'Acht', 'Neun'],
'teens_de' => ['Zehn', 'Elf', 'Zwölf', 'Dreizehn', 'Vierzehn', 'Fünfzehn', 'Sechzehn', 'Siebzehn', 'Achtzehn', 'Neunzehn'],
'tens_de' => ['', 'Zehn', 'Zwanzig', 'Dreißig', 'Vierzig', 'Fünfzig', 'Sechzig', 'Siebzig', 'Achtzig', 'Neunzig'],
'thousands_de' => ['', 'Tausend', 'Million', 'Milliarde', 'Billion'],
'zero_de' => 'Null',
'negative_de' => 'Negativ ',
'hundred_de' => ' Hundert ',
'and_de' => ' und ',
'cents_de' => ' Cent',
// Italian words
'units_it' => ['', 'Uno', 'Due', 'Tre', 'Quattro', 'Cinque', 'Sei', 'Sette', 'Otto', 'Nove'],
'teens_it' => ['Dieci', 'Undici', 'Dodici', 'Tredici', 'Quattordici', 'Quindici', 'Sedici', 'Diciassette', 'Diciotto', 'Diciannove'],
'tens_it' => ['', 'Dieci', 'Venti', 'Trenta', 'Quaranta', 'Cinquanta', 'Sessanta', 'Settanta', 'Ottanta', 'Novanta'],
'thousands_it' => ['', 'Mille', 'Milione', 'Miliardo', 'Bilione'],
'zero_it' => 'Zero',
'negative_it' => 'Negativo ',
'hundred_it' => ' Cento ',
'and_it' => ' e ',
'cents_it' => ' Centesimi',
]
];
use NumberToWord\NumberToWords\Traits\NumbersToWords;
$words = NumbersToWords::numbersToWords(12000, 'en');
echo $words; // Outputs: Twelve Thousand
use NumberToWord\NumberToWords\Traits\WordsToNumbers;
$numbers = WordsToNumbers::wordsToNumbers('Twelve Thousand', 'en');
echo $numbers; // Outputs: 12000
// with form.
return $form
->schema([
Section::make()
->schema([
NumbersToWordsInput::make('price')
->label('Numbers To Words')
->lang('en'),
WordsToNumbersInput::make('word')
->label('Words To Numbers')
->lang('en'),
// with table.
return $table
->columns([
NumbersToWordsColumn::make('price')
->label("Numbers To Words")
->lang('en')
->suffix(' DA')
->badge()
->color('success'),
WordsToNumbersColumn::make('word')
->label("Words To Numbers")
->lang('en')
->suffix(' DA')
->badge()
->color('primary'),
])
bash
php artisan vendor:publish --tag="numbertowords-config"