title: Shorten a text string in PHP
body: <p>Is there a way to trim a text string in PHP so it has a certain number of characters? For instance, if I had the string:</p>
  
  <p><code>$string = "this is a string";</code></p>
  
  <p>How could I trim it to say:</p>
  
  <p><code>$newstring = "this is";</code></p>
  
  <p>This is what I have so far, using <code>chunk_split()</code>, but it isn't working. Can anyone improve on my method?</p>
  
  <pre><code>function trimtext($text)
  {
  $newtext = chunk_split($text,15);
  return $newtext;
  }
  </code></pre>
  
  <p>I also looked at <a href="https://stackoverflow.com/questions/972010/shorten-string-in-php-full-words-only?rq=1">this</a> question, but I don't really understand it.</p>