当前位置:Gxlcms > PHP教程 > 把全角数字转为半角数字

把全角数字转为半角数字

时间:2021-07-01 10:21:17 帮助过:16人阅读

把全角数字转为半角数字
  1. //把全角数字转为半角数字
  2. function GetAlabNum($fnum){
  3. $nums = array("0","1","2","3","4","5","6","7","8","9");
  4. //OSPHP.com.CN
  5. $fnums = "0123456789";
  6. for($i=0;$i<=9;$i++) $fnum = str_replace($nums[$i],$fnums[$i],$fnum); //OsPHP.COM.CN
  7. $fnum = ereg_replace("[^0-9.]|^0{1,}","",$fnum);
  8. if($fnum=="") $fnum=0;
  9. return $fnum;
  10. }
  11. ?>

人气教程排行