首頁  >  文章  >  後端開發  >  PHP把全角數字轉為半角數字

PHP把全角數字轉為半角數字

WBOY
WBOY原創
2016-07-25 08:44:28805瀏覽
  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. ?>
复制代码

PHP


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn