Replace cut_text with own regex-based version

develop
Sven Slootweg 12 years ago
parent 4245c1f206
commit 589dbae474

@ -174,6 +174,25 @@ function strip_tags_attr($string, $allowtags = NULL, $allowattributes = NULL)
return $string;
}
function cut_text($input, $length)
{
if(strlen($input) > $length)
{
if(preg_match("/^(.{0,{$length}})\W/s", $input, $matches))
{
return $matches[1] . "...";
}
else
{
return "";
}
}
else
{
return $input;
}
}
function cut_text($value, $length)
{
/* Thanks to highstrike at gmail dot com (http://www.php.net/manual/en/function.substr.php#80247) */

Loading…
Cancel
Save