How can i convert English numbers being retrieved from the database to Arabic numeral symbols in PHP.
EDIT: Here're some examples of what Arabic numerals look like. I live in an Arab country, so please don't go around explaining to me what Arabic numerals look like. If you can help, good and well. I don't need bogus ideas.
If you are referring to what Wikipedia calls eastern arabic / indic numerals, a simple replace operation should do.
Are you trying to convert e.g. Sixty-nine to تسعة وستون? Try if you can call the Google Translate service or another translation service. Otherwise, you should write your own numeral parser and use your knowledge of the Arabic language to translate it to Arabic. (But using a translation service would be a lot easier.) (Then again, PHP might already have a function that writes out numbers and digits in the proper way.)
I would suggest u to try using resource file for different language especially if the contents are known. Example: 2 file language files, 1 named language_EN, another language_AR where langauge_EN is to store the values in english, and language_AR for arabic.
so for instance u want store the number "1"
in langauge_EN, do something like this. number.one=1
then in langauge_AR, (pretend x is the number "1" in arabic, but I guess unicode is preferred) number.one=x
so after u retrieve from database and knowing that it is number, your raw result comes out to be "one".
so use number.+[result from database] to load from the langauage_AR This method is quite widely used in webpages which allow toggling of language. So at any time u need to convert back to english, just change back to language_EN. This works not only for number. Gd Luck
Definitions
The answer
I wrote a couple of functions (gist.github.com) a while back.
Demo (3v4l.org)
Code
Simple solution with strtr:
To convert from Eastern Arabic to Arabic:
Or you can just download and use this class from: http://www.phpclasses.org/package/6626-PHP-Convert-numbers-to-Arabic-representation.html (Tested and working). Cheers.