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

  1. function getalabnum($fnum)
  2. {
  3. $nums = array("0","1","2","3","4","5","6","7","8","9","+","-","%",".");
  4. $fnums = "0123456789+-%.";
  5. for($i=0;$i<count($nums);$i++){
  6. if($nums[$i]==$fnum) return $fnums[$i];
  7. }//开源代码phpfensi.com
  8. return $fnum;
  9. }
  10. //实例应用
  11. echo getalabnum('6'); // 6