<?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 for Fetched from hammerspace</title>
	<atom:link href="http://hammerspace.co.uk/comments/feed" rel="self" type="application/rss+xml" />
	<link>http://hammerspace.co.uk</link>
	<description>Web, Words and Photography</description>
	<lastBuildDate>Sat, 11 Feb 2012 17:56:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>Comment on Truncate at space, Zend View Helper by David Jonathan Marland</title>
		<link>http://hammerspace.co.uk/2011/10/truncate-at-space-zend-view-helper#comment-149</link>
		<dc:creator>David Jonathan Marland</dc:creator>
		<pubDate>Sat, 11 Feb 2012 17:56:05 +0000</pubDate>
		<guid isPermaLink="false">http://hammerspace.co.uk/?p=121#comment-149</guid>
		<description>Good spot. Somehow I copied a non-working version into this post. I have taken your suggestion and modified accordingly. Thanks.
I did make a small change where if no space is found it returns empty, as we want to avoid cutting a word at all costs.</description>
		<content:encoded><![CDATA[<p>Good spot. Somehow I copied a non-working version into this post. I have taken your suggestion and modified accordingly. Thanks.<br />
I did make a small change where if no space is found it returns empty, as we want to avoid cutting a word at all costs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Truncate at space, Zend View Helper by Steve</title>
		<link>http://hammerspace.co.uk/2011/10/truncate-at-space-zend-view-helper#comment-132</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Thu, 02 Feb 2012 12:56:23 +0000</pubDate>
		<guid isPermaLink="false">http://hammerspace.co.uk/?p=121#comment-132</guid>
		<description>Sorry, the code snippet in my previous post got messed up. Here it is on pastebin: http://pastebin.com/aiZrSa1m</description>
		<content:encoded><![CDATA[<p>Sorry, the code snippet in my previous post got messed up. Here it is on pastebin: <a href="http://pastebin.com/aiZrSa1m" rel="nofollow">http://pastebin.com/aiZrSa1m</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>Comment on Truncate at space, Zend View Helper by Steve</title>
		<link>http://hammerspace.co.uk/2011/10/truncate-at-space-zend-view-helper#comment-131</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Thu, 02 Feb 2012 12:47:32 +0000</pubDate>
		<guid isPermaLink="false">http://hammerspace.co.uk/?p=121#comment-131</guid>
		<description>There&#039;s a problem with your code in that it truncates to the last occurrence of white space in the string, no matter what length is specified. This means it always returns everything but the last word, unless you&#039;re using midWord().

Here&#039;s my take on a fix for the render() function. I also changed it to return an empty string if the specified length is &lt; 1 which I think is more desirable (for my uses anyway).

&lt;code&gt;
    public function render()
    {
        // Return empty string if max length _length = string length
        if ($this-&gt;_length &gt;= strlen($this-&gt;_string)) {
        	return $this-&gt;_string;
        }

        // Return truncated string
        if ($this-&gt;_cutatspace) {
            while (strlen($this-&gt;_string) &gt; $this-&gt;_length) {
                $cutPos = strrpos($this-&gt;_string, &#039; &#039;, -1);
                if ($cutPos === false) {
                    $cutPos = $this-&gt;_length;
                }
                $this-&gt;_string = trim(substr($this-&gt;_string, 0, $cutPos));
            }
        } else {
            $this-&gt;_string = trim(substr($this-&gt;_string, 0, $this-&gt;_length));
        }
        return $this-&gt;_string . $this-&gt;_postfix;
    }
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>There&#8217;s a problem with your code in that it truncates to the last occurrence of white space in the string, no matter what length is specified. This means it always returns everything but the last word, unless you&#8217;re using midWord().</p>
<p>Here&#8217;s my take on a fix for the render() function. I also changed it to return an empty string if the specified length is &lt; 1 which I think is more desirable (for my uses anyway).</p>
<p><code><br />
    public function render()<br />
    {<br />
        // Return empty string if max length _length = string length<br />
        if ($this-&gt;_length &gt;= strlen($this-&gt;_string)) {<br />
        	return $this-&gt;_string;<br />
        }</p>
<p>        // Return truncated string<br />
        if ($this-&gt;_cutatspace) {<br />
            while (strlen($this-&gt;_string) &gt; $this-&gt;_length) {<br />
                $cutPos = strrpos($this-&gt;_string, ' ', -1);<br />
                if ($cutPos === false) {<br />
                    $cutPos = $this-&gt;_length;<br />
                }<br />
                $this-&gt;_string = trim(substr($this-&gt;_string, 0, $cutPos));<br />
            }<br />
        } else {<br />
            $this-&gt;_string = trim(substr($this-&gt;_string, 0, $this-&gt;_length));<br />
        }<br />
        return $this-&gt;_string . $this-&gt;_postfix;<br />
    }<br />
</code></p>
]]></content:encoded>
	</item>
</channel>
</rss>

