将英文数字转换为阿拉伯数字 [英] Convert English numbers to Arabic numerals

查看:40
本文介绍了将英文数字转换为阿拉伯数字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将数据库中检索到的英文数字转换为 PHP 中的阿拉伯数字符号.

How can i convert English numbers being retrieved from the database to Arabic numeral symbols in PHP.

以下是阿拉伯数字外观的一些示例.我住在一个阿拉伯国家,所以请不要到处向我解释阿拉伯数字的样子.如果你能帮上忙,那很好.我不需要虚假的想法.

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.

http://upload.wikimedia.org/wikipedia/commons/thumb/2/21/Arabic_numerals-en.svg/500px-Arabic_numerals-en.svg.png

推荐答案

如果您指的是维基百科所说的 东方阿拉伯/印度数字,应该做一个简单的替换操作.

If you are referring to what Wikipedia calls eastern arabic / indic numerals, a simple replace operation should do.

$western_arabic = array('0','1','2','3','4','5','6','7','8','9');
$eastern_arabic = array('٠','١','٢','٣','٤','٥','٦','٧','٨','٩');

$str = str_replace($western_arabic, $eastern_arabic, $str);

这篇关于将英文数字转换为阿拉伯数字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆