$cstr[] = $ns1;
}
}
}
$estr = isset($estr[0])?$estr[0]:array();
$nstr = isset($nstr[0])?$nstr[0]:array();
return
<A
class=infotextkey
href="http://www.jbxue.com/w3school/php/func_array_merge.html"
target=_blank>array_merge</A>($nstr,$estr,$cstr);
}
?>
結果是
:
Array ( [0] => www [1] => jbxue [2] => net [3] => 这是 [4] => 是我 [5] => 我的 [6] => 的网 [7]
=> 网站 )
如果以上结果转换为区位码,则如下代码所示:
<?php
foreach ($result as $s) {
$s = iconv('UTF-8','GB2312',$s);
$code[] = gbCode($s);
}
$code = implode(" ", $code);
echo $code;
function gbCode($str) {
$return = null;
if (!preg_match("/^[\x80-\xff]{2,}$/",$str)) return $str;
$len = strlen($str);
for ($i= 0; $i< $len; $i=$i+2) {
$return
.=
<A
class=infotextkey
href="http://www.jbxue.com/shouce/php5/function.sprintf.html"
target=_blank>sprintf()</A>("%02d%02d",ord($str{$i})-160,ord($str{$i+1})-160);
}
return $return;
}
?>