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 about how to replace ASCII characters on the Internet. 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 );
}