Make an excerpt with php without cutt last word
<p>Hy! I'm trying to make an excerpt for long titles but last word should not be cutted. I've read an related topic of this question but it seems it refer to another problem (on search result). here's my function now </p>

<pre><code>function excerpt($title) {
        $new = substr($title, 0, 27);

        if (strlen($title) &gt; 30) {
            return $new.'...';
        } else {
            return $title;
        }
    }
</code></pre>