Last Updated: February 25, 2016
·
433
· pastimelife

Function limit text

<?
/**
 * © 2012-2013, [ Abstract Codify ] Abstractcodify.com All Rights Reserved.
 * truncate text to a specific length
 *
 * @param String $string
 * @param Integer $limit
 * @param String $suffix
 * @return String truncated string
 */
function limit_text($string, $limit, $suffix = '&hellip;')
{
    if (mb_strlen($string, 'UTF-8') > $limit)
    {
        $string = mb_substr($string, 0, $limit, 'UTF-8') . $suffix;
    }

    return $string;
}
?>