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 = '…')
{
if (mb_strlen($string, 'UTF-8') > $limit)
{
$string = mb_substr($string, 0, $limit, 'UTF-8') . $suffix;
}
return $string;
}
?>
Written by Object-C
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Limi
Authors
pastimelife
431
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#