background image

 
 
代码如下:
 

function

 _cny_map_unit(

$list

,

$units

) { 

$ul

=

count

(

$units

); 

$xs

=

array

(); 

foreach

 (

array_reverse

(

$list

as

 

$x

) { 

$l

=

count

(

$xs

); 

if

 (

$x

!="0" || !(

$l

%4)) 

$n

=(

$x

=='0'?'':

$x

).(

$units

[(

$l

-1)%

$ul

]); 

else

 

$n

=

is_numeric

(

$xs

[0][0])?

$x

:''; 

array_unshift

(

$xs

,

$n

); 

return

 

$xs

}
?>
 
使用方法:直接传递数字参数即可,下面的实例打印出来便是数字大写。输出:壹万贰仟
壹佰贰拾壹圆

 

复制代码 代码如下:
 
<?php

echo

 cny('12121');

?>