Wednesday, August 26, 2009

Limit Text and Strip tags in PHP

$content = $post->post_content;

$limit = 280;

if (strlen($content) > $limit)

$content = substr($content, 0, strrpos(substr($content, 0, $limit), ' ')) . '...';

echo strip_tags($content);

No comments: