<code>function utf_substr($str,$len)<br />{<br /> for($i=0;$i<$len;$i++)<br /> {<br /> $temp_str=substr($str,0,1);<br /> if(ord($temp_str) > 127){<br /> $i++;<br /> if($i<$len) {<br /> $new_str[]=substr($str,0,3);<br /> $str=substr($str,3);<br /> }<br /> }<br /> else {<br /> $new_str[]=substr($str,0,1);<br /> $str=substr($str,1);<br /> }<br /> }<br /> return join($new_str);<br />}</code>