PHP user-defined function: full-width half-width mutual conversion .? PHPfunctionSBC_DBC ($ str, $ args2) {Halfwidth and fullwidth conversion function. if the second parameter is 0, it is halfwidth to fullwidth. if it is 1, from the full-width to the half-width $ DBCarray (, 2 Function SBC_DBC ($ str, $ args2) {// Halfwidth and fullwidth conversion function. if the second parameter is 0, it is halfwidth to fullwidth. if it is 1, it is fullwidth to halfwidth.
$ DBC = array (
0, 1, 2, 3, 4,
5, 6, 7, 8, 9,
A, B, C, D, E,
F, G, H, I, J,
K, L, M, N, O,
P, Q, R, S, T,
U, V, W, X, Y,
Z, a, B, c, d,
E, f, g, h, I,
J, k, l, m, n,
O, p, q, r, s,
T, u, v, w, x,
Y, z ,-,,:,
.,/, % ,#,
! ,@,&,(,),
<,> ,",',? ,
[,], {,}, \,
|, +, =, _, ^,
$, ~, And hour
);
$ SBC = array (// halfwidth
0, 1, 2, 3, 4,
5, 6, 7, 8, 9,
A, B, C, D, E,
F, G, H, I, J,
K, L, M, N, O,
P, Q, R, S, T,
U, V, W, X, Y,
Z, a, B, c, d,
E, f, g, h, I,
J, k, l, m, n,
O, p, q, r, s,
T, u, v, w, x,
Y, z ,-,,:,
.,/, % ,#,
!, @,&,(,),
<,> ,",,?,
[,], {,}, \,
|, =, _, ^,
$ ,~, '
);
If ($ args2 = 0)
Return str_replace ($ SBC, $ DBC, $ str); // halfwidth to fullwidth
If ($ args2 = 1)
Return str_replace ($ DBC, $ SBC, $ str); // full-width to half-width
Else
Return false;
}
// Function call
$ Str = "alskdf ";
Echo $ str;
Echo"
";
Echo SBC_DBC ($ str, 0 );
Echo SBC_DBC ($ str, 1 );
?>
Http://www.bkjia.com/PHPjc/486070.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/486070.htmlTechArticle? PHP function SBC_DBC ($ str, $ args2) {// Halfwidth and fullwidth conversion function. if the second parameter is 0, it is halfwidth to fullwidth. if it is 1, it is the full-width to the half-width $ DBC = array (0, 1, 2...