There is a wood has encountered financial related development, good Arabic numerals, must be the whole form of Chinese characters display, this is just, but also to the whole into traditional Chinese characters. It's very upsetting.
The following will share with you I encountered the need to use PHP to convert Arabic numerals into Chinese characters when the processing method, can be summed up as a function, the specific study to go.
function Num2char ($num, $mode =true) {
$char = Array (' 0 ', ' one ', ' two ', ' three ', ' four ', ' V ', ' VI ', ' VII ', ' VIII ', ' IX ');
$char = Array (' 0 ', ' one ', ' II ', ' three ', ' establishments ', ' Wu ', ' Lu ', ' qi ', ' ba ', ' JIU ');
$DW = Array (' ', ' ten ', ' hundred ', ' thousand ', ' ', ' million ', ' billion ', ' trillion ');
$DW = Array (' ', ' pick ', ' bai ', ' thousand ', ' ', ' million ', ' Yi ', ' trillion ');
$dec = ' point '; $dec = ' dot ';
$retval = ";
if ($mode) {
Preg_match_all ('/^0* (\d*) \.? (\d*)/', $num, $ar);
}else{
Preg_match_all ('/(\d*) \.? (\d*)/', $num, $ar);
}
if ($ar [2][0]! = ") {
$retval = $dec. Ch_num ($ar [2][0],false); If there are decimals, the decimal is first processed recursively
}
if ($ar [1][0]! = ") {
$str = Strrev ($ar [1][0]);
for ($i =0; $i
$out [$i] = $char [$STR [$i]];
if ($mode) {
$out [$i]. = $STR [$i]! = ' 0 '? $DW [$i%4]: ";
if ($str [$i]+ $str [$i-1] = = 0) {
$out [$i] = ';
}
if ($i%4 = = 0) {
$out [$i]. = $DW [4+floor ($i/4)];
}
}
}
$retval = Join (', Array_reverse ($out)). $retval;
}
return $retval;
}
Examples of Use:
Echo ' 300045.0123: '. Num2char (' 300045.0123 ');//www.scutephp.com