<?xml version="1.0" encoding="utf-8" ?><rss version="2.0" xml:base="https://www.webmaster-forums.net/crss/node/1032902" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title></title>
    <link>https://www.webmaster-forums.net/crss/node/1032902</link>
    <description></description>
    <language>en</language>
          <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-substr-without-breaking-tags#comment-1192598</link>
    <description> &lt;p&gt;Thanks Dux0r, that helps a lot &lt;img src=&quot;https://www.webmaster-forums.net/misc/smileys/smile.png&quot; title=&quot;Smiling&quot; alt=&quot;Smiling&quot; class=&quot;smiley-content&quot; /&gt;&lt;/p&gt;
 </description>
     <pubDate>Sun, 05 Feb 2006 02:33:32 +0000</pubDate>
 <dc:creator>IanD</dc:creator>
 <guid isPermaLink="false">comment 1192598 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-substr-without-breaking-tags#comment-1192461</link>
    <description> &lt;p&gt;I recently needed a function to do exactly the same thing. I modified one I found on PHP.net&lt;/p&gt;
&lt;p&gt;It isn&#039;t 100% perfect but it does the job.&lt;/p&gt;
&lt;p&gt;function html_substr($posttext, $minimum_length, $length_offset) {&lt;br /&gt;
   // The approximate length you want the concatenated text to be&lt;br /&gt;
   $minimum_length = 200;&lt;br /&gt;
   // The variation in how long the text can be&lt;br /&gt;
   // in this example text length will be between 200-10=190 characters&lt;br /&gt;
   // and the character where the last tag ends&lt;br /&gt;
   $length_offset = 10;&lt;br /&gt;
   // Reset tag counter &amp;amp; quote checker&lt;br /&gt;
   $tag_counter = 0;&lt;br /&gt;
   $quotes_on = FALSE;&lt;br /&gt;
   // Check if the text is too long&lt;br /&gt;
   if (strlen($posttext) &amp;gt; $minimum_length) {&lt;br /&gt;
       // Reset the tag_counter and pass through (part of) the entire text&lt;br /&gt;
       for ($i = 0; $i &amp;lt; strlen($posttext); $i++) {&lt;br /&gt;
// Load the current character and the next one&lt;br /&gt;
// if the string has not arrived at the last character&lt;br /&gt;
$current_char = substr($posttext,$i,1);&lt;br /&gt;
if ($i &amp;lt; strlen($posttext) - 1) {&lt;br /&gt;
    $next_char = substr($posttext,$i + 1,1);&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
    $next_char = &quot;&quot;;&lt;br /&gt;
}&lt;br /&gt;
// First check if quotes are on&lt;br /&gt;
if (!$quotes_on) {&lt;br /&gt;
    // Check if it&#039;s a tag&lt;br /&gt;
    // On a &quot;&amp;lt;&quot; add 3 if it&#039;s an opening tag (like &lt;a or add if&gt;)&lt;br /&gt;
    if ($current_char == &quot;&amp;lt;&quot;) {&lt;br /&gt;
        if ($next_char == &quot;/&quot;) {&lt;br /&gt;
      $tag_counter++;&lt;br /&gt;
        }&lt;br /&gt;
        else {&lt;br /&gt;
 $tag_counter = $tag_counter + 3;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
    // Slash signifies an ending (like &lt;/a&gt; or ... /&amp;gt;)&lt;br /&gt;
    // substract 2&lt;br /&gt;
    if ($current_char == &quot;/&quot;) $tag_counter = $tag_counter - 2;&lt;br /&gt;
    // On a &quot;&amp;gt;&quot; substract 1&lt;br /&gt;
    if ($current_char == &quot;&amp;gt;&quot;) $tag_counter--;&lt;br /&gt;
    // If quotes are encountered, start ignoring the tags&lt;br /&gt;
    // (for directory slashes)&lt;br /&gt;
    if ($current_char == &quot;\&quot;&quot;) $quotes_on = TRUE;&lt;br /&gt;
}&lt;br /&gt;
else {&lt;br /&gt;
    // IF quotes are encountered again, turn it back off&lt;br /&gt;
    if ($current_char == &quot;\&quot;&quot;) $quotes_on = FALSE;&lt;br /&gt;
}&lt;/p&gt;
&lt;p&gt;// Check if the counter has reached the minimum length yet,&lt;br /&gt;
// then wait for the tag_counter to become 0, and chop the string there&lt;br /&gt;
if ($i &amp;gt; $minimum_length - $length_offset &amp;amp;&amp;amp; $tag_counter == 0) {&lt;br /&gt;
    $posttext = substr($posttext,0,$i + 1) . &quot;...&quot;;&lt;br /&gt;
    return $posttext;&lt;br /&gt;
}&lt;br /&gt;
       }&lt;br /&gt;
   }&lt;br /&gt;
  return $posttext;&lt;br /&gt;
}&lt;/p&gt;
 </description>
     <pubDate>Fri, 03 Feb 2006 12:13:44 +0000</pubDate>
 <dc:creator>Dux0r</dc:creator>
 <guid isPermaLink="false">comment 1192461 at https://www.webmaster-forums.net</guid>
  </item>
  <item>
    <title></title>
    <link>https://www.webmaster-forums.net/serverside-scripting/getting-substr-without-breaking-tags#comment-1192420</link>
    <description> &lt;p&gt;i suck at doing it, but look into the &lt;a href=&quot;http://www.php.net/manual/en/function.eregi-replace.php&quot; class=&quot;bb-url&quot;&gt;http://www.php.net/manual/en/function.eregi-replace.php&lt;/a&gt; function to replace everything between the &amp;lt; and &amp;gt; (including the &amp;lt;&amp;gt;&#039;s) with an empty string.&lt;/p&gt;
&lt;p&gt;-Greg&lt;/p&gt;
 </description>
     <pubDate>Fri, 03 Feb 2006 00:26:52 +0000</pubDate>
 <dc:creator>Greg K</dc:creator>
 <guid isPermaLink="false">comment 1192420 at https://www.webmaster-forums.net</guid>
  </item>
  </channel>
</rss>
