[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: arabic numbering in php? -- A possibly faster/better solution



Hi, Ahmed, 
Salam wa alaikum,

While the PHP solution you devised for Arabic numerals using HTML character entity references
works just fine, I thought I would present an alternative solution which is simpler
and, because it uses the built-in PHP "strtr()" function, may be faster:

   http://eyegene.ophthy.med.umich.edu/arabic/index.php

In this solution, a "$digits" array has a one-to-one mapping between
the ASCII numeric digits and the Arabic digits U+0660 -> U+0669.
The code is written directly in UTF-8.
We then simply use PHP's built-in "strtr()" function to translate
occurrences of ASCII numerals to the Arabic numerals.  So conversion
takes only one line of PHP code.  The web page is generated as
an XHTML page using "charset=utf-8" and the body tag is given a CSS
style for RTL.

Best Wishes --

-- Ed Trager

On Saturday 2005.11.05 21:29:12 -0600, ahmed at piousity dot net wrote:
> alsalam 3alaikum wa 3eid mubarak all,
> hope all is well insha'Allah.  i had a quick question... i tried googling
> for a bit but couldn't find anything really (altho i might have missed
> something).
> 
> i want to do something like:
> 
> for ($i=0; $i<290; $i++){
>   // display i in arabic or append it to a string or something
> }
> 
> is there an easy way to do this?
> 
> thanks,
> wsalam 3alaikum,
> -ahmed
> 

> _______________________________________________
> Developer mailing list
> Developer at arabeyes dot org
> http://lists.arabeyes.org/mailman/listinfo/developer