fredyounan
1/5/2014 - 9:23 PM

truncateString.php

function truncateString($string, $limit = 12) {
    if (strlen($string) <= $limit) {
        $string = strip_tags($string);
    } else {
        $string = strip_tags(substr($string, 0, strpos($string, " ", $limit))).'...';
    }
    return $string;
}