解决中文被截成乱码的问题
<?php//2007-04-09 Create By Rain Chan
function left($str, $len) { //解决中文被截成乱码的问题
$arr = str_split($str);
$i = 0;
foreach ($arr as $chr) {
if (ord($chr) > 128)
$add = $add ? 0 : 1;
$i++;
if ($i == $len)
break;
}
return substr($str, 0, $len + $add);
}
//echo left($_GET['str'], $_GET['len']);
?>