function myTruncate2($string, $limit, $break=" ", $pad="")
{
// return with no change if string is shorter than $limit
if(strlen($string) <= $limit) return $string;
$string = substr($string, 0, $limit);
if(false !== ($breakpoint = strrpos($string, $break))) {
$string = substr($string, 0, $breakpoint);
}
return $string . $pad; }
Call to function as below :
$str_add1 = $this->myTruncate2($data->ahli_coalamat, 48);
No comments:
Post a Comment