欢迎来到福编程网,本站提供各种互联网专业知识!

php代码把全角数字转为半角数字

发布时间:2007-12-10 作者: 来源:转载
//把全角数字转为半角数字functionGetAlabNum($fnum){$nums=array('0','1','2','3','4','5','6','7','8','9','.','-','+',':');$fnums=array('0','1','2','3','4','5','6','7','8','9','.',
//把全角数字转为半角数字
functionGetAlabNum($fnum){
$nums=array('0','1','2','3','4','5','6','7','8','9','.','-','+',':');
$fnums=array('0','1','2','3','4','5','6','7','8','9','.','-','+',':');
$fnlen=count($fnums);
for($i=0;$i<$fnlen;$i++)$fnum=str_replace($nums[$i],$fnums[$i],$fnum);
$slen=strlen($fnum);
$oknum='';
for($i=0;$i<$slen;$i++){
if(ord($fnum[$i])>0x80)$i++;
else$oknum.=$fnum[$i];
}
if($oknum=="")$oknum=0;
return$oknum;
}

相关推荐