<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>dev.fuzzee.co.uk &#187; brainfart</title>
	<atom:link href="http://dev.fuzzee.co.uk/tag/brainfart/feed/" rel="self" type="application/rss+xml" />
	<link>http://dev.fuzzee.co.uk</link>
	<description>stuff that pops into my head ... technical stuff.</description>
	<lastBuildDate>Sun, 18 Apr 2010 13:39:16 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Avoiding temporary array assignment in PHP</title>
		<link>http://dev.fuzzee.co.uk/2009/09/avoiding-temporary-array-assignment-in-php/</link>
		<comments>http://dev.fuzzee.co.uk/2009/09/avoiding-temporary-array-assignment-in-php/#comments</comments>
		<pubDate>Thu, 03 Sep 2009 20:09:29 +0000</pubDate>
		<dc:creator>adrian</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[brainfart]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[zend-framework]]></category>

		<guid isPermaLink="false">http://dev.fuzzee.co.uk/?p=102</guid>
		<description><![CDATA[Even though I&#8217;ve been developing with PHP for a number of years, I still enjoy discovering new ways of working. Even though the stdClass object is about as basic as you can get, it&#8217;s never struck me as being a worthwhile tool. Today, I was storing an associative array of objects in a Zend_Registry. Because [...]]]></description>
			<content:encoded><![CDATA[<p>Even though I&#8217;ve been developing with PHP for a number of years, I still enjoy discovering new ways of working. Even though the stdClass object is about as <strong>basic</strong> as you can get, it&#8217;s never struck me as being a worthwhile tool. <span id="more-102"></span>Today, I was storing an associative array of objects in a <a href="http://framework.zend.com/manual/en/zend.registry.html">Zend_Registry</a>. Because PHP&#8217;s syntax does not support array accessors on method calls, I had to perform a temporary assignation, as follows:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$arrayOfObjects</span> <span style="color: #339933;">=</span> Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stuff'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$object</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$arrayOfObjects</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'key'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$object</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">foo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">// of course, I could do:</span>
<span style="color: #666666; font-style: italic;">// $arrayOfObjects['key']-&gt;foo();</span>
<span style="color: #666666; font-style: italic;">// but I still need the temporary assignment</span></pre></div></div>

<p>Because I decided to put a <strong>stdClass</strong> object into the Zend_Registry, the code reads a little more fluently:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">Zend_Registry<span style="color: #339933;">::</span><span style="color: #004000;">get</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'stuff'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">key</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">foo</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>As far as I&#8217;m aware, there is no significant penalty for using stdClass, but the results are much nicer.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev.fuzzee.co.uk/2009/09/avoiding-temporary-array-assignment-in-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
