How to convert full-width numbers to half-width numbers in php code: use replace conversion, the code is [for($i=0;$i<$fnlen;$i) $fnum = str_replace($nums[$i] ,$fnums[$i],$fnum);].
How to convert full-width numbers to half-width numbers in php code:
Convert full-width numbers to half-width numbers
function GetAlabNum($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; }
If you want to learn more about programming, please pay attention to the php training column!
The above is the detailed content of How to convert full-width numbers to half-width in php code. For more information, please follow other related articles on the PHP Chinese website!