php 全角数字转为半角数字的简单示例

前端之家收集整理的这篇文章主要介绍了php 全角数字转为半角数字的简单示例前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
PHP全角数字转为半角数字感兴趣的小伙伴,下面一起跟随编程之家 jb51.cc的小编两巴掌来看看吧!

/**
 * PHP全角数字转为半角数字
 *
 * @param 
 * @arrange 512-笔记网: www.jb51.cc
 **/
<?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; 
} 

/***   来自编程之家 jb51.cc(jb51.cc)   ***/
原文链接:https://www.f2er.com/php/528120.html

猜你在找的PHP相关文章