This article mainly introduces the PHP full-width half-width conversion function, and lists all the available full-width columns for replacement. For more information, see.
This article mainly introduces the PHP full-width half-width conversion function, and lists all the available full-width columns for replacement. For more information, see.
I tried to replace ASCII characters on the Internet and found many inexplicable problems. Finally, replace it with the following character replacement method. replace all the currently available full corners.
The Code is as follows:
/**
* Full-width conversion to halfwidth
*
* @ Param string $ str
* @ Return string
*/
Public function Sbc2Dbc ($ 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 ',
'(' => '(', ')' => ')', '[' => '(', ']' => ')', '[' => '[', ']' => ']', '<' => '[', '<' => ']', '=>' "','" '=> '"',
''' => '\ '', ''' =>' \'', '{' => '{', '}' => '}', '=>' <',' "'=>', '%' => '%', '+' => '+ ', '-' => '-', '-' => '-',
'~ '=> '~ ',': '=> ':','. '=> '. ',', '=>', ','; '=> ';','? '=> '? ','! '=> '! ','... '=> '-',
'''' => '|', '"' => '"', ''' => ''', ''' => ''', '|' => '|', 'Hangzhou' => '"', '=>', '×' => '*', 'yun' => '~ ','. '=>'. ',' * '=> '*',
'&' => '&', '<' => '<', '>' => ',' $ '=>' $ ', '@' => '@', '^' => '^', '_' => '_', '"' => '"', '¥' => '$', '=>' = ',
'\' => '\', '/' => '/'
);
Return strtr ($ str, $ arr );
}
,