Limit String Characters (Cut String Length) in PHP

PHP function that limit characters of a string:

function limit_string_length($string, $limit = 20)
{
    return (strlen($string) > $limit) ? sprintf('%s', substr($string, 0, $limit)."...") : $string;
}

More Related Posts