<?php
function utf82gb($text, &$charset) {
  $p = "/[xf0-xf7][x80-xbf]{3}|[xe0-xef][x80-xbf]{2}|[xc2-xdf][x80-xbf]|[x01-x7f]+/";
  preg_match_all($p,$text,$r);
  $utf8 = array_flip($charset);
  foreach($r[0] as $k=>$v)
    if(isset($utf8[$v]))
      $r[0][$k] = $utf8[$v];
  return join('',$r[0]);
}$s = gb2utf8('这是对照表的测试');
echo utf82gb($s,$charset);
?>
唠叨在喜悦村的,link:http://php.phpx.com/happy/thread-90509-3-1.html