Home >Backend Development >PHP Tutorial >PHP converts full-width numbers to half-width numbers

PHP converts full-width numbers to half-width numbers

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-07-25 08:44:28894browse
  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

PHP


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