title: Shortening text tweet-like without cutting links inside
body: <p>I've got a string like this:</p>
  
  <pre><code>I love @kevinrose 's new website &lt;a href="http://kevinrose.com"&gt;Link&lt;/a&gt;
  </code></pre>
  
  <p>And I have this function:</p>
  
  <pre><code>function short($string, $max = 255) {
      if (strlen($string) &gt;= $max) {
          $string = mb_substr($string, 0, $max - 5, 'utf-8') . '...';
      } return $string;
  }
  </code></pre>
  
  <p>If I cut the screen at 50, it will end up being something that :</p>
  
  <pre><code>I love @kevinrose 's new website &lt;a href="http://kevinr...
  </code></pre>
  
  <p>Which will of course kill the html.</p>
  
  <p>Is there an easy way I can avoid cutting the a href tag (before or preferably after) without breaking the HTML ?</p>
  
  <p>I need to keep my tags of course.</p>
  
  <p>Thank you</p>