php function like wordpress the_content()
<p>aIs there a function in php (like Wordpress's the_content()) that can limit a text string without breaking the html tags that may be within it?</p>

<pre><code>//example:
echo substr ('&lt;p&gt;this &lt;a&gt;is&lt;/a&gt; a test&lt;/p&gt;', 0, 10);

//output: "&lt;p&gt;this &lt;a"
//desired output: "&lt;p&gt;this &lt;/p&gt;"
</code></pre>
