function SplitStr($str)
{
$len = strlen ($str);
$i = 0;
$outputcn = "";
$outputen = "";
while ($i<$len)
{
if (preg_match("/^[".chr(0xa1)."-".chr(0xff)."]+$/",$str[$i]))
{
$outputcn .= $str[$i].$str[$i+1];
$i += 2;
}
else
{
$outputen .= $str[$i];
$i += 1;
}
}
echo "原字符串为:".$str."<br>";
if ($outputcn != "")
echo "中文部分字符串:".$outputcn."<br>";
if ($outputen != "")
echo "英文部分字符串:".$outputen."<br>";
}
$str = "abcd喜悦国际村asdf";
SplitStr($str);
作者: Sjolzy
--EOF--