Home  >  Article  >  Backend Development  >  PHP code to convert full-width numbers to half-width numbers_PHP tutorial

PHP code to convert full-width numbers to half-width numbers_PHP tutorial

WBOY
WBOYOriginal
2016-07-21 15:54:03742browse

//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;
}

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/318569.htmlTechArticle//Convert full-width numbers to half-width numbers functionGetAlabNum($fnum){ $nums=array('0', '1','2','3','4','5','6','7','8','9',' ','-','+',': '); $fnums=array('0','1'...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn