Home >php教程 >php手册 >php代码把全角数字转为半角数字

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

WBOY
WBOYOriginal
2016-06-13 12:30:341169browse

//把全角数字转为半角数字
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    $slen = strlen($fnum);
    $oknum = '';
    for($i=0;$i        if(ord($fnum[$i]) > 0x80) $i++;
        else $oknum .= $fnum[$i];
    }
    if($oknum=="") $oknum=0;
    return $oknum;
}

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
Previous article:php木马攻击防御之道Next article:[PHP]实用函数9