Convert English numbers to Arabic numerals

前端 未结 7 687
余生分开走
余生分开走 2020-12-10 01:58

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.

7条回答
  •  北海茫月
    2020-12-10 02:23

    Definitions

    • Western arabic numerals: "1234567890".
    • Eastern arabic numerals: "١٢٣٤٥٦٧٨٩٠".

    The answer

    I wrote a couple of functions (gist.github.com) a while back.

    Demo (3v4l.org)

        echo arabic_w2e("1234567890"); // Outputs: ١٢٣٤٥٦٧٨٩٠
        echo arabic_e2w("١٢٣٤٥٦٧٨٩٠"); // Outputs: 1234567890
    

    Code

提交回复
热议问题