| 热门文章 |
 |
|
| 编辑推荐 |
 |
|
|
|
|
|
作者:longnetpro
来源:ChinaUnix.net 点击: 更新:2006-12-19
|
|
rator($trans[$rr]); } } } $ss = ''; if ($sh != '' && $sr != ''){ $ss = $sh. $this->addSeperator('and') .$sr; }else{ $ss = $sh.$sr; } return $ss; } function trans_int($int){ if ($int <= 20) return $this->addSeperator($this->resource['group_int'][intval($int)]); $groups = explode(',', $this->split_group($int)); $groups = array_reverse($groups); $cgroup = $this->resource['group']['group_number']; $result = ''; foreach($groups as $key => $group_int){ $sgroup = ''; $k = $key % $cgroup; if ((int)$group_int != 0){ $sgroup = $this->resource['group'][$k]; $sgroup = $this->addSeperator($sgroup); $sgroup = $this->trans_group_int($group_int).$sgroup; } $ss = ''; if ($k == 0 && $key >= $cgroup) $ss = $this->addSeperator($this->resource['group'][$cgroup]); $result = $sgroup.$ss.$result; } return $result; } function trans_fraction($fraction){ if ($fraction == '') return ''; $fraction = preg_replace('/([0-9])/e', '$this->addSeperator($this->resource[\'group_int\'][\\1])', $fraction); return $fraction; } function getText($isupper = false){ $text = parent::getText(); if ($isupper){ $text = strtoupper($text); } return $text; } }
//---------------------------------------------------------------------------
class TextNumber_zh_CN extends TextNumber { var $groupLength = 4; var $wordSeperated = false;
function TextNumber_zh_CN(){ $this->__construct(); } function __construct(){ $this->resource = array( 'group_int' => array( 0 => '零', 1 => '一', 2 => '二', 3 => '三', 4 => '四', 5 => '五', 6 => '六', 7 => '七', 8 => '八', 9 => '九' ), 'group_int_digital' => array( 0 => '', 1 => '十', 2 => '百', 3 => '千' ), 'group' => array( 0 => '', 1 => '万', 2 => '亿', 3 => '兆', '-' => '负', '.' => '点', 'group_number' => 3 ), 'trans_upper' => array( '一' => '壹', '二' => '贰', '三' => '叁', '四' => '肆', '五' => '伍', '六' => '陆', '七' => '柒', '八' => '捌', '九' => '玖', '十' => '拾', '百' => '佰', '千' => '仟' ) ); } function trans_group_int($group_int){ $si = strrev($group_int); $ss = ''; $i = 0; if (preg_match('/^([0]+)/', $si, $matches)){ $i = strlen($matches[1]); } for(; $i < strlen($si); $i++){ $s = ($si{$i} == '0')? '' : $this->addSeperator($this->resource['group_int_digital'][$i]); $ss = $si{$i}.$s.$ss; } return $ss; } function trans_int($int){ if ($int < 10) return $this->addSeperator($this->resource['group_int'][intval($int)]); /* if ($int < 20){ $sint = $this->addSeperator($this->resource['group_int'][10]); $sint .= $this->addSeperator($this->resource['group_int'][$int % 10]); return $sint; } */ $groups = explode(',', $this->split_group($int)); $groups = array_reverse($groups); $cgroup = $this->resource['group']['group_number']; $result = ''; foreach($groups as $key => $group_int){ $sgroup = ''; $k = $key % $cgroup; if ((int)$group_int != 0){ $sgroup = $this->resource['group'][$k]; $sgroup = $this->addSeperator($sgroup); $sgroup = $this->trans_group_int($group_int).$sgroup; if ($k != 0 && substr($group_int, -1) == '0') $sgroup .= '0'; }else{ $sgroup = '0'; } $ss = ''; if ($k == 0 && $key >= $cgroup){ $ss = $this->addSeperator($this->resource['group'][$cgroup]); if (substr($group_int, -1) == '0') $ss .= '0'; } $result = $sgroup.$ss.$result; } $result = preg_replace('/[0]+/', '0', $result); $result = preg_replace('/(^|[^1-9])0([^1-9]|$)/', '\\1\\2', $result); $result = preg_replace('/([0-9])/e', '$this->addSeperator($this->resource[\'group_int\'][\\1])', $result); return $result; } function trans_fraction($fraction){ if ($fraction == '') return ''; $fraction = preg_replace('/([0-9])/e', '$this->addSeperator($this->resource[\'group_int\'][\\1])', $fraction); return $fraction; } function getText($isupper 上一页 [1] [2] [3] 下一页
|
|
|