function SBC_DBC($str,$args2) { //Half-width and full-width conversion function, if the second parameter is 0, it is from half-width to full-width; if it is 1, it is from full-width to half-width
$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 , ス , スb , c , d ,
ス , f , g , h , i , <🎜> k , k , ス , m , n ,
o , p , q , r , s , < | @ , & , ( , ) ,
< , > , " , ' , ? ,
[ , ] , { , } , \ ,
| , + , = , _ , ^ ,
¥ ,  ̄ , `
);
$SBC = array( //Half-width
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); //Half-width to full-width
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.html
www.bkjia.com
true