Spell numbers in the Arabic idiom. This function is very useful for e-Commerce applications in Arabic for example. It accepts almost any numeric value and convert it into an equivalent string of words in written Arabic language and take care of feminine and Arabic grammar rules.
If you ever have to create an Arabic PHP application built around invoicing or accounting, you might find this method useful. Its sole reason for existence is to help you translate integers into their spoken-word equivalents in Arabic language.How is this useful? Well, consider the typical invoice: In addition to a description of the work done, the date, and the hourly or project cost, it always includes a total cost at the end, the amount that the customer is expected to pay. To avoid any misinterpretation of the total amount, many organizations (mine included) put the amount in both words and figures; for example, $1,200 becomes "one thousand and two hundred dollars." You probably do the same thing every time you write a check.
Now take this scenario to a Web-based invoicing system. The actual data used to generate the invoice will be stored in a database as integers, both to save space and to simplify calculations. So when a printable invoice is generated, your Web application will need to convert those integers into words, this is more clarity and more personality.
<?php
$Arabic = new \ArPHP\I18N\Arabic();
$Arabic->setNumberFeminine(1);
$Arabic->setNumberFormat(1);
$integer = 141592653589;
$text = $Arabic->int2str($integer);
echo "<center>$integer<br />$text</center>";
<?php
$Arabic = new \ArPHP\I18N\Arabic();
$Arabic->setNumberFeminine(2);
$Arabic->setNumberFormat(2);
$integer = 141592653589;
$text = $Arabic->int2str($integer);
echo "<center>$integer<br />$text</center>";
-2749.317
سالب ألفين وسبعمئة وتسع وأربعين فاصلة ثلاثمئة وسبع عشرة
<?php
$Arabic = new \ArPHP\I18N\Arabic();
$Arabic->setNumberFeminine(2);
$Arabic->setNumberFormat(2);
$integer = '-2749.317';
$text = $Arabic->int2str($integer);
echo "<p dir=ltr align=center>$integer<br />$text</p>";
7.25
سبعة دنانير ومئتان وخمسون فلسا
<?php
$Arabic = new \ArPHP\I18N\Arabic();
$Arabic->setNumberFeminine(1);
$Arabic->setNumberFormat(1);
$number = 7.25;
$text = $Arabic->money2str($number, 'KWD', 'ar');
echo "<p align=center>$number<br />$text</p>";
9 تعليقات
16 صندوقا
<?php
$Arabic = new \ArPHP\I18N\Arabic();
$number = 9;
$text = $Arabic->arPlural('تعليق', $number);
$text = str_replace('%d', $number, $text);
echo "<p align=center>$text</p>";
$number = 16;
$text = $Arabic->arPlural('صندوق', $number, 'صندوقان', 'صناديق', 'صندوقا');
$text = str_replace('%d', $number, $text);
echo "<p align=center>$text</p>";
1975/8/2 9:43 صباحا
١٩٧٥/٨/٢ ٩:٤٣ صباحا
<?php
$Arabic = new \ArPHP\I18N\Arabic();
$text1 = '1975/8/2 9:43 صباحا';
$text2 = $Arabic->int2indic($text1);
echo "<p align=center>$text1<br />$text2</p>";
17
السابعة عشرة
<?php
$Arabic = new \ArPHP\I18N\Arabic();
$Arabic->setNumberFeminine(2);
$Arabic->setNumberFormat(2);
$Arabic->setNumberOrder(2);
$integer = '17';
$text = $Arabic->int2str($integer);
echo "<p align=center>$integer<br />$text</p>";
مليار ومئتين وخمسة وستين مليون وثلاثمئة وثمانية وخمسين ألف وتسعمئة وتسعة وسبعين
1265358979
<?php
$Arabic = new \ArPHP\I18N\Arabic();
$string = 'مليار ومئتين وخمسة وستين مليون وثلاثمئة وثمانية وخمسين ألف وتسعمئة وتسعة وسبعين';
$integer = $Arabic->str2int($string);
echo "<p align=center>$string<br />$integer</p>";