php全角数字转为半角数字
来源:phperz.com 作者:phperz.com 发布时间:2011-11-29
php把全角数字转为半角数字的函数 ? function GetAlabNum($fnum){ $nums = array(0,1,2,3,4,5,6,7,8,9); //OSPHP.com.CN $fnums = 0123456789; for($i=0;$i=9;$i++) $fnum = str_replace($nums[$i],$fnums[$i],$fnum); $fnum = ereg_replace([^0-9.]|^0{1,},
php把全角数字转为半角数字的函数
<?
function GetAlabNum($fnum){
$nums = array("0","1","2","3","4","5","6","7","8","9");
$fnums = "0123456789";
for($i=0;$i<=9;$i++) $fnum = str_replace($nums[$i],$fnums[$i],$fnum);
$fnum = ereg_replace("[^0-9.]|^0{1,}","",$fnum);
if($fnum=="") $fnum=0;
return $fnum;
}
?>
延伸阅读:人民币大小写转换(PHP版)intval函数不能格式化超过9位的数字PHP打印环状数字圈js格式化数字为两位小数限制input只输入数字php数字补零的两种方法