function substr_utf8( $str, $from , $len )
{
return preg_replace( '#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
'' , $str );
};
คือถ้า ข้อมูลมีขนาดมากกว่า 564 ตัวอักษร จะเกิด warning
Message: preg_replace() [function.preg-replace]: Compilation failed: regular expression is too large at offset 96
มีวิธีแก้ไขมั้ยครับ
{
return preg_replace( '#^(?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$from.'}'.
'((?:[\x00-\x7F]|[\xC0-\xFF][\x80-\xBF]+){0,'.$len.'}).*#s',
'' , $str );
};
คือถ้า ข้อมูลมีขนาดมากกว่า 564 ตัวอักษร จะเกิด warning
Message: preg_replace() [function.preg-replace]: Compilation failed: regular expression is too large at offset 96
มีวิธีแก้ไขมั้ยครับ
for($i=0;$i<strlen_utf8($string);$i++)
echo substr_utf8($string,$i,1);
เรืยกใช้แบบนี่ครับ
echo substr_utf8($string,$i,1);
เรืยกใช้แบบนี่ครับ