Spell Numbers in the Arabic Idiom:

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.


Example Output 1: المعدود مذكر مرفوع

141592653589
مئة و واحد و أربعون مليار و خمسمئة و اثنان و تسعون مليون و ستمئة و ثلاثة و خمسون ألف و خمسمئة و تسعة و ثمانون

Example Code 1:

<?php
    $Arabic 
= new \ArPHP\I18N\Arabic();

    
$Arabic->setNumberFeminine(1);
    
$Arabic->setNumberFormat(1);

    
$integer 141592653589;

    
$text $Arabic->int2str($integer);

    echo 
"<center>$integer<br />$text</center>";

Example Output 2: المعدود مؤنث منصوب أو مجرور

141592653589
مئة و واحدة و أربعين مليار و خمسمئة و اثنتين و تسعين مليون و ستمئة و ثلاث و خمسين ألف و خمسمئة و تسع و ثمانين

Example Code 2:

<?php
    $Arabic 
= new \ArPHP\I18N\Arabic();

    
$Arabic->setNumberFeminine(2);
    
$Arabic->setNumberFormat(2);

    
$integer 141592653589;
    
    
$text $Arabic->int2str($integer);
    
    echo 
"<center>$integer<br />$text</center>";

Example Output 3: المعدود مؤنث منصوب أو مجرور وهو سالب بفاصلة عشرية

-2749.317
سالب ألفين و سبعمئة و تسع و أربعين فاصلة ثلاثمئة و سبع عشرة


Example Code 3:

<?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>";

Example Output 4: العملات العربية

7.25
سبعة دنانير و مئتان و خمسون فلسا


Example Code 4:

<?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>";

Example Output 5: صيغ الجمع

9 تعليقات

16 صندوقا


Example Code 5:

<?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>";

Example Output 6: الأرقام الهندية

1975/8/2 9:43 صباحا
١٩٧٥/٨/٢ ٩:٤٣ صباحا


Example Code 6:

<?php
    $Arabic 
= new \ArPHP\I18N\Arabic();
    
    
$text1 '1975/8/2 9:43 صباحا';
    
$text2 $Arabic->int2indic($text1);
    
    echo 
"<p align=center>$text1<br />$text2</p>";

Example Output 7: ترتيب لمعدود مؤنث منصوب أو مجرور

17
السابعة عشرة


Example Code 7:

<?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>";

Example Output 8: تحويل الرقم المكتوب إلى عدد صحيح من جديد

مليار و مئتين و خمسة و ستين مليون و ثلاثمئة و ثمانية و خمسين ألف و تسعمئة و تسعة و سبعين
1265358979


Example Code 8:

<?php
    $Arabic 
= new \ArPHP\I18N\Arabic();
    
    
$string  'مليار و مئتين و خمسة و ستين مليون و ثلاثمئة و ثمانية و خمسين ألف و تسعمئة و تسعة و سبعين';

    
$integer $Arabic->str2int($string);
    
    echo 
"<p align=center>$string<br />$integer</p>";