php 面试题
function transfer($v){ $danwei = array('分','角','零','块','十','百','千','万','十','百','千','亿'); $hanzi = array('零','一','二','三','四','五','六','七','八','九','十'); $result = array(); $v = strval($v); $v = sprintf('%0.2f',$v); $len = strlen($v); for ($i = $len;$i>=0;$i--){ if(!empty($v[$i-1]) && $v[$i-1] != '.') $result[] = $hanzi[$v[$i-1]].$danwei[$len - $i]; } $result = array_reverse($result); print_r(implode($result)); //var_dump($v); exit; } transfer(243453336.45898989);