<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Code Snippet: Trimming text on word boundaries in PHP</title>
	<atom:link href="http://www.tierra-innovation.com/blog/2008/12/16/code-snippet-trimming-text-on-word-boundaries-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.tierra-innovation.com/blog/2008/12/16/code-snippet-trimming-text-on-word-boundaries-in-php/</link>
	<description>Innovation in technology, strategy and design</description>
	<lastBuildDate>Sat, 21 Aug 2010 16:01:33 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: FG</title>
		<link>http://www.tierra-innovation.com/blog/2008/12/16/code-snippet-trimming-text-on-word-boundaries-in-php/comment-page-1/#comment-91</link>
		<dc:creator>FG</dc:creator>
		<pubDate>Wed, 17 Dec 2008 06:15:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.tierra-innovation.com/blog/?p=302#comment-91</guid>
		<description>$text = wordwrap($text, $max_length, &quot;\n&quot;);
$text = strstr($text, &quot;\n&quot;, true);

// wordwrap will insert &quot;\n&quot; at $max_length intervals conforming to word boundaries
// strstr as of 5.3.0 will return $text upto the first &quot;\n&quot;</description>
		<content:encoded><![CDATA[<p>$text = wordwrap($text, $max_length, &#8220;\n&#8221;);<br />
$text = strstr($text, &#8220;\n&#8221;, true);</p>
<p>// wordwrap will insert &#8220;\n&#8221; at $max_length intervals conforming to word boundaries<br />
// strstr as of 5.3.0 will return $text upto the first &#8220;\n&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harry Fuecks</title>
		<link>http://www.tierra-innovation.com/blog/2008/12/16/code-snippet-trimming-text-on-word-boundaries-in-php/comment-page-1/#comment-90</link>
		<dc:creator>Harry Fuecks</dc:creator>
		<pubDate>Wed, 17 Dec 2008 01:30:14 +0000</pubDate>
		<guid isPermaLink="false">http://www.tierra-innovation.com/blog/?p=302#comment-90</guid>
		<description>Ummm - http://www.reddit.com/r/PHP/comments/7juw9/code_snippet_trimming_text_on_word_boundaries_in/c06v3xr</description>
		<content:encoded><![CDATA[<p>Ummm &#8211; <a href="http://www.reddit.com/r/PHP/comments/7juw9/code_snippet_trimming_text_on_word_boundaries_in/c06v3xr" rel="nofollow">http://www.reddit.com/r/PHP/comments/7juw9/code_snippet_trimming_text_on_word_boundaries_in/c06v3xr</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://www.tierra-innovation.com/blog/2008/12/16/code-snippet-trimming-text-on-word-boundaries-in-php/comment-page-1/#comment-89</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Wed, 17 Dec 2008 00:51:29 +0000</pubDate>
		<guid isPermaLink="false">http://www.tierra-innovation.com/blog/?p=302#comment-89</guid>
		<description>Just double-checked strrpos() and the offset is where it stops scanning for characters and not where is starts so using it would find the first space after the requested text length and not the one preceeding it.  I have updated the code to use strrpos in a different way to get rid of the loop.</description>
		<content:encoded><![CDATA[<p>Just double-checked strrpos() and the offset is where it stops scanning for characters and not where is starts so using it would find the first space after the requested text length and not the one preceeding it.  I have updated the code to use strrpos in a different way to get rid of the loop.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Doug</title>
		<link>http://www.tierra-innovation.com/blog/2008/12/16/code-snippet-trimming-text-on-word-boundaries-in-php/comment-page-1/#comment-88</link>
		<dc:creator>Doug</dc:creator>
		<pubDate>Wed, 17 Dec 2008 00:16:50 +0000</pubDate>
		<guid isPermaLink="false">http://www.tierra-innovation.com/blog/?p=302#comment-88</guid>
		<description>frans: Cool. I wasn&#039;t aware of the offset parameter was available in strrpos().</description>
		<content:encoded><![CDATA[<p>frans: Cool. I wasn&#8217;t aware of the offset parameter was available in strrpos().</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: frans</title>
		<link>http://www.tierra-innovation.com/blog/2008/12/16/code-snippet-trimming-text-on-word-boundaries-in-php/comment-page-1/#comment-87</link>
		<dc:creator>frans</dc:creator>
		<pubDate>Wed, 17 Dec 2008 00:05:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.tierra-innovation.com/blog/?p=302#comment-87</guid>
		<description>Instead of 

while (    ($text_length &gt; 0)
            &amp;&amp; (substr($text, $text_length - 1, 1) != &quot; &quot;))
      $text_length--;
if ($text_length &lt;= 0)

you could say

$text_length = strrpos($text, &#039; &#039;, $text_length);
if ($text_length === false)</description>
		<content:encoded><![CDATA[<p>Instead of </p>
<p>while (    ($text_length &gt; 0)<br />
            &amp;&amp; (substr($text, $text_length &#8211; 1, 1) != &#8221; &#8220;))<br />
      $text_length&#8211;;<br />
if ($text_length &lt;= 0)</p>
<p>you could say</p>
<p>$text_length = strrpos($text, &#8216; &#8216;, $text_length);<br />
if ($text_length === false)</p>
]]></content:encoded>
	</item>
</channel>
</rss>
