', ']]>', $text);
$text = preg_replace('@@si', '', $text);
$text = preg_replace('@]*?>.*?@si', '', $text);
$text = strip_tags($text);
$text = trim($text);
$words = explode(' ', $text, $length + 1);
if (count($words) > $length)
{
array_pop($words);
$text = trim(implode(' ', $words)) . '...';
}
}
$text = preg_replace('/\s\s+/', ' ', $text);
return $text;
}
}