Users often write full-width English characters or punctuation marks. Sometimes the system cannot recognize them. Therefore, convert all full-width characters into normal half-width characters to reduce the problem. In fact, the principle is very simple, it is also very stupid, that is, to replace all the full-width characters with the corresponding half-width characters, from the open source code of ecshop. *** Convert a string
Users often write full-width English characters or punctuation marks. Sometimes the system cannot recognize them. Therefore, convert all full-width characters into normal half-width characters to reduce the problem. In fact, the principle is very simple, it is also very stupid, that is, to replace all the full-width characters with the corresponding half-width characters, from the open source code of ecshop. /***
Users often write full-width English characters or punctuation marks. Sometimes the system cannot recognize them. Therefore, convert all full-width characters into normal half-width characters to reduce the problem. In fact, the principle is very simple, it is also very stupid, that is, to replace all the full-width characters with the corresponding half-width characters, from the open source code of ecshop.
/*** Enclose a string with full-width numbers, letters, spaces, or '% + -() 'character conversion to the corresponding halfwidth character ** @ access public * @ param string $ str string to be converted ** @ return string $ str processed string */function make_semiangle ($ str) {$ arr = array ('0' => '0', '1' => '1', '2' => '2 ', '3' => '3', '4' => '4', '5' => '5', '6' => '6 ', '7' => '7', '8' => '8', '9' => '9', 'A' => 'A ', 'B' => 'B', 'C' => 'C', 'D' => 'D', 'E' => 'E ', 'F' => 'F', 'G' => 'G', 'H' => 'h', 'I' => 'I', 'J' => 'J', 'K' => 'k', 'L' => 'l', 'M' => 'M', 'n' => 'n ', 'o' => 'O', 'p' => 'P', 'q' => 'Q', 'R' => 'R ', 'S '=>'s', 't' => 'T', 'U' => 'U', 'V' => 'V ', 'W' => 'w', 'x' => 'x', 'y' => 'y', 'z' => 'Z ', 'A' => 'A', 'B' => 'B', 'C' => 'C', 'D' => 'D ', 'E' => 'E', 'F' => 'F', 'G' => 'G', 'H' => 'h ', 'I' => 'I', 'J' => 'J', 'K' => 'k', 'L' => 'l ', 'M' => 'M', 'n' => 'n', 'O' => 'O', 'p' => 'P ', 'q' =>' Q', 'R' => 'R', 's' => 's', 't' => 'T', 'U' => 'U ', 'V' => 'V', 'w' => 'w', 'x' => 'x', 'y' => 'y ', 'Z' => 'Z', '(' => '(', ')' => ')', '[' => '[', ']' => ']', '[' => '[', ']' => ']', '<' => '[', '〗' => ']', '=>' [',' "'=>'] ', ''' => '[', ''' => ']', '{' => '{', '}' => '}', '=>' <', '"' => ',' % '=>' % ',' + '=>' + ','-'=> '-', '-' => '-','~ '=>'-',': '=> ':','. '=> '. ',', '=>', '=> '. ',', '=> '. ','; '=> ',','? '=> '? ','! '=> '! ','... '=>'-', ''' =>' | ',' "'=>'" ', ''' => ''', ''' => ''', '|' => '|', 'Region' => '"','' => ''); return strtr ($ str, $ arr );}
Original article address: php converts full-width characters into half-width characters. Thank you for sharing it with the original author.