Splitting strings, preserve HTML tags and words
<p>I need to take an input from a WYSIWYG and break it down to having 33 (or approximate) characters per line. If it hits the limit, I need to insert a new line. Here is what I came up with:</p>

<pre><code>for($i=0; $i &lt; strlen($string); $i++) {
  if ($i % 33 == 0 &amp;&amp; $i != 0) {
    $characters[] = '\r';
  }
  $characters[] = $string[$i];
}

$result = implode($characters);
</code></pre>

<p>This breaks HTML tags and words. I need to ignore HTML tags, and allow words to finish before breaking a line. What is a better way to achieve this?</p>
