Cobain fungsi ini.
function cut_karakter($char,$length_char){
if(strlen($char) > $length_char){
$char=preg_replace('/<img.*src="(.*?)".*\/?>/', '', $char); /*tidak menampilkan gbr jika ada*/
$char=preg_replace('/<div.*style="(.*?)".*\/?>/', '', $char);/*tidak menampilkan style jika ada*/
$char=preg_replace('/<div.*\/?>/', '', $char);
for ($i=$length_char;$i<=$length_char+1000;$i++){
if(substr($char,$i,1)==" " or substr($char,$i,1)==""){
$new_char = substr($char,0,$i);
return $new_char." [...]";
break;
}
}
}
else return $char;
}