php - Numbers to text
PHP中文网
PHP中文网 2017-06-13 09:22:16
0
2
1026

How to quickly convert numbers into text
For example, 1 => one, 2=> two, ..., 15=》Fifteen
What I am currently thinking about is to save Chinese characters into a In array

$arr = ['一','二','三','四','五','六','七','八','九','十'];

But this is too troublesome
How to convert the input numbers into Chinese? Is there an easier way?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(2)
代言

Too free,,,,,,,,,,,,,,,,,,,,,,

<?php

$str = 1237124129124;

//将一个字符串转换为数组
$arr = str_split((string)$str,1);

$cns = ['零','一','二','三','四','五','六','七','八','九'];

foreach ($arr as $key) {
    echo $cns[$key];
}

//一二三七一二四一二九一二四
phpcn_u1582

Why not use key-value pairs

$arr = [ 1=>'一', 2=>'二' ];
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template