PHP custom function: full-width and half-width conversion_PHP tutorial

WBOY
Release: 2016-07-13 17:42:15
Original
998 people have browsed it

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

TechArticle?PHP function SBC_DBC($str,$args2) { //Half-width and full-width conversion function, second parameter If it is 0, it is half-width to full-width; if it is 1, it is full-width to half-width $DBC = array( 0 , 1 , 2...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template