split a string PHP
<p>I found this php script : </p>

<blockquote>
  <p>// strip tags to avoid breaking any html $string =
  strip_tags($string);</p>
  
  <p>if (strlen($string) > 500) {</p>

<pre><code>// truncate string
$stringCut = substr($string, 0, 500);

// make sure it ends in a word so assassinate doesn't become ass...
$string = substr($stringCut, 0, strrpos($stringCut, ' ')).'... &lt;a href="/this/story"&gt;Read More&lt;/a&gt;';  } echo $string;
</code></pre>
</blockquote>

<p>create by webbiedave. Now my question is how can I specifi in strrpos to found for space or dot ?</p>

<p>So if I limit string to 22 and if I had something like StackOverFlow is the best site ever --> will output StackOverFlow is the ... and if I had something like <a href="http://stackoverflow.com">http://stackoverflow.com</a> is the best site ever --> will output only ... because he doesn't found space and string lenght > 22 .How can I modify this script to cut text if find a dot in the string so <a href="http://stackoverflow.com">http://stackoverflow.com</a> is the best site ever --> become <a href="http://stackoverflow">http://stackoverflow</a> ... ?</p>
