Home > Article > Backend Development > Analysis of source code application examples for converting Chinese characters to location codes using PHP_PHP tutorial
The problem of how to convert Chinese characters to location codes in PHP has always troubled most programmers, so I believe the following source code example will be of great help to everyone.
The following is the quoted content:
global $PHP_SELF;
//echo $PHP_SELF;
$t1=$_POST[textfield1];
$t2=$_POST[textfield2];
$t3=$_POST[textfield3];
$t4=$_POST[textfield4];
// Chinese characters--location code
if($t1!=""){
$t2= sprintf("%02d%02d",ord($t1[0])-160,ord($t1[1])-160);
//echo $t2;
}
// Location code--Chinese characters
if($t3!=""){
$t4 = chr(substr($t3,0,2)+160).chr(substr($t3,2 ,2)+160);
//echo $t4;
}
?>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
class="STYLE1">Chinese character location code query system |