PHP 阿拉伯数字转中文表述
如101转成一百零一
function num2cn($number) { $number = intval ( $number ); $capnum = array ( "零", "一", "二", "三", "四", "五", "六", "七", "八", "九" ); $capdigit = array ( "", "十", "百", "千", "万" ); $data_arr = str_split ( $number ); $count = count ( $data_arr ); for($i = 0; $i < $count; $i ++) { $d = $capnum [$data_arr [$i]]; $arr [] = $d != '零' ? $d . $capdigit [$count - $i - 1] : $d; } $cncap = implode ( "", $arr ); $cncap = preg_replace ( "/(零)+/", "0", $cncap ); // 合并连续“零” $cncap = trim ( $cncap, '0' ); $cncap = str_replace ( "0", "零", $cncap ); // 合并连续“零” $cncap == '一十' && $cncap = '十'; $cncap == '' && $cncap = '零'; return $cncap; }