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講師
Too free,,,,,,,,,,,,,,,,,,,,,,
<?php
$str = 1237124129124;
//將一個字符串轉(zhuǎn)換為數(shù)組
$arr = str_split((string)$str,1);
$cns = ['零','一','二','三','四','五','六','七','八','九'];
foreach ($arr as $key) {
echo $cns[$key];
}
//一二三七一二四一二九一二四