phpÏÂʵÏÖÒ»¸ö°¢À­²®Êý×ÖתÖÐÎÄÊý×ֵĺ¯Êý

5年以前  |  阅读数:744 次  |  编程语言:PHP 

Èç¹uÒªÓÃÓÚ½ð¶iµÄת»»£¬¶ÔСÊý²¿*ֵĴ¦ÀiÒª×oÒ»ÏÂÐÞ¸Ä

<?php
function ch_num($num,$mode=true) {
$char = array("Áa","Ò¼","*¡","Èþ","ËÁ","Îe","½","Æa","°Æ","¾Á");
$dw = array("","Ê°","°Û","Ǫ","","Èf","ƒ|","Õ×");
$dec = "uc";
$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); //Èç¹uÓÐСÊý£¬Ïȵݹe´¦ÀiСÊý
if($ar[1][0] != "") {
$str = strrev($ar[1][0]);
for($i=0;$i<strlen($str);$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;
}

//echo ch_num("12345006789001.123");
//echo ch_num("880079.1234");
echo ch_num("300045.0123");

?>

Copyright© 2013-2020

All Rights Reserved 京ICP备2023019179号-8