Home  >  Article  >  Backend Development  >  Convert full-width numbers to half-width numbers

Convert full-width numbers to half-width numbers

WBOY
WBOYOriginal
2016-07-25 09:10:091184browse
Convert full-width numbers to half-width numbers
  1. //Convert full-width numbers to half-width numbers
  2. function GetAlabNum($fnum){
  3. $nums = array("0","1","2","3","4" ,"5","6","7","8","9");
  4. //OSPHP.com.CN
  5. $fnums = "0123456789";
  6. for($i=0;$i<= 9;$i++) $fnum = str_replace($nums[$i],$fnums[$i],$fnum); //OsPHP.COM.CN
  7. $fnum = ereg_replace("[^0-9.]| ^0{1,}","",$fnum);
  8. if($fnum=="") $fnum=0;
  9. return $fnum;
  10. }
  11. ?>
Copy code


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