如何剪切字符串并添加悬浮标记?

I wan to cut a string in around 300 characters and add "..." at the end if it was above that number of characters. I know it can't be very hard but I don't want to cut a word in half so I wanted to know how do I do it so it doesn't end up like: "And the bird suddenl..."

Thanks

http://php.net/wordwrap

$str = 'A very long string here';
$str = wordwrap($str, 100);
$str = explode("
", $str);
$str = $str[0] . '...';
function limit($str, $limit, $append = '...') {
    return preg_replace('/\S*$/', '', mb_substr($str, 0, $limit)) . $append;
}