<?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: An alternative way to create arrays</title>
	<atom:link href="http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/feed/" rel="self" type="application/rss+xml" />
	<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/</link>
	<description>baking cakes with CakePHP</description>
	<lastBuildDate>Thu, 11 Mar 2010 15:41:30 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Abhimanyu Grover</title>
		<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/comment-page-1/#comment-45422</link>
		<dc:creator>Abhimanyu Grover</dc:creator>
		<pubDate>Tue, 18 Dec 2007 20:55:26 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/#comment-45422</guid>
		<description>Ah, what a shortcut... real cool !!</description>
		<content:encoded><![CDATA[<p>Ah, what a shortcut&#8230; real cool !!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/comment-page-1/#comment-45363</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Tue, 18 Dec 2007 16:56:34 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/#comment-45363</guid>
		<description>@Lech, Brandon: Thanks for your comments!

@Lech: I fixed your comment by adding pre tags. 

Yes, that&#039;s a possible way to structure arrays. I think it is a matter of preference whether you like it that way or not. Personally, I don&#039;t like it. I prefer to create private methods to create the sub arrays.

I think in most applications the impact of the described approach on the performance can be ignored ;-)

@Brandon: Yes, that works. I wasn&#039;t aware you could use it in this way, too.</description>
		<content:encoded><![CDATA[<p>@Lech, Brandon: Thanks for your comments!</p>
<p>@Lech: I fixed your comment by adding pre tags. </p>
<p>Yes, that&#8217;s a possible way to structure arrays. I think it is a matter of preference whether you like it that way or not. Personally, I don&#8217;t like it. I prefer to create private methods to create the sub arrays.</p>
<p>I think in most applications the impact of the described approach on the performance can be ignored ;-)</p>
<p>@Brandon: Yes, that works. I wasn&#8217;t aware you could use it in this way, too.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brandon P</title>
		<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/comment-page-1/#comment-45332</link>
		<dc:creator>Brandon P</dc:creator>
		<pubDate>Tue, 18 Dec 2007 15:12:28 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/#comment-45332</guid>
		<description>Great post! If I&#039;m not mistaken, Set class can also be instantiated:

$expectedPosts = new Set();
$expectedPosts-&gt;insert(&#039;0.Post.id&#039;, 3);
$expectedPosts-&gt;insert(&#039;0.Post.title&#039;, &#039;a title&#039;);
$expectedPosts-&gt;insert(&#039;0.Post.content&#039;, &#039;some content&#039;);
$expectedPosts-&gt;insert(&#039;1.Post.id&#039;, 4);
$expectedPosts-&gt;insert(&#039;1.Post.title&#039;, &#039;another title&#039;);
$expectedPosts-&gt;insert(&#039;1.Post.content&#039;, &#039;some other content&#039;);
$data = $expectedPosts-&gt;get();</description>
		<content:encoded><![CDATA[<p>Great post! If I&#8217;m not mistaken, Set class can also be instantiated:</p>
<p>$expectedPosts = new Set();<br />
$expectedPosts-&gt;insert(&#8216;0.Post.id&#8217;, 3);<br />
$expectedPosts-&gt;insert(&#8216;0.Post.title&#8217;, &#8216;a title&#8217;);<br />
$expectedPosts-&gt;insert(&#8216;0.Post.content&#8217;, &#8217;some content&#8217;);<br />
$expectedPosts-&gt;insert(&#8216;1.Post.id&#8217;, 4);<br />
$expectedPosts-&gt;insert(&#8216;1.Post.title&#8217;, &#8216;another title&#8217;);<br />
$expectedPosts-&gt;insert(&#8216;1.Post.content&#8217;, &#8217;some other content&#8217;);<br />
$data = $expectedPosts-&gt;get();</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lech</title>
		<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/comment-page-1/#comment-45252</link>
		<dc:creator>Lech</dc:creator>
		<pubDate>Tue, 18 Dec 2007 09:59:35 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/#comment-45252</guid>
		<description>Doh, html pre tag was stripped, so indentation is missing.. Please view the source to see what I&#039;ve ment in my previous comment :)</description>
		<content:encoded><![CDATA[<p>Doh, html pre tag was stripped, so indentation is missing.. Please view the source to see what I&#8217;ve ment in my previous comment :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Lech</title>
		<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/comment-page-1/#comment-45251</link>
		<dc:creator>Lech</dc:creator>
		<pubDate>Tue, 18 Dec 2007 09:52:28 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/#comment-45251</guid>
		<description>For more readability I&#039;d rather use a bit different array notation:

&lt;pre&gt;
$expectedPosts  = array(
        array(
                &#039;Post&#039;  =&gt; array(
                        &#039;id&#039;        =&gt; 3,
                        &#039;title&#039;     =&gt; &#039;a title&#039;,
                        &#039;content&#039;   =&gt; &#039;some content&#039;
                    )
            ),
        array(
                &#039;Post&#039;  =&gt; array(
                        &#039;id&#039;        =&gt; 4,
                        &#039;title&#039;     =&gt; &#039;another title&#039;,
                        &#039;content&#039;   =&gt; &#039;some other content&#039;
                    )
            ),
    );
&lt;/pre&gt;

or using less space (worse case):

&lt;pre&gt;
$expectedPosts  = array(
        array(&#039;Post&#039; =&gt; array(
                &#039;id&#039;        =&gt; 3,
                &#039;title&#039;     =&gt; &#039;a title&#039;,
                &#039;content&#039;   =&gt; &#039;some content&#039;
            )),
        array(&#039;Post&#039; =&gt; array(
                &#039;id&#039;        =&gt; 4,
                &#039;title&#039;     =&gt; &#039;another title&#039;,
                &#039;content&#039;   =&gt; &#039;some other content&#039;
            )),
    );
&lt;/pre&gt;

And don&#039;t forget to avoid Set::insert in production because of performance ;)</description>
		<content:encoded><![CDATA[<p>For more readability I&#8217;d rather use a bit different array notation:</p>
<pre>
$expectedPosts  = array(
        array(
                'Post'  =&gt; array(
                        'id'        =&gt; 3,
                        'title'     =&gt; 'a title',
                        'content'   =&gt; 'some content'
                    )
            ),
        array(
                'Post'  =&gt; array(
                        'id'        =&gt; 4,
                        'title'     =&gt; 'another title',
                        'content'   =&gt; 'some other content'
                    )
            ),
    );
</pre>
<p>or using less space (worse case):</p>
<pre>
$expectedPosts  = array(
        array('Post' =&gt; array(
                'id'        =&gt; 3,
                'title'     =&gt; 'a title',
                'content'   =&gt; 'some content'
            )),
        array('Post' =&gt; array(
                'id'        =&gt; 4,
                'title'     =&gt; 'another title',
                'content'   =&gt; 'some other content'
            )),
    );
</pre>
<p>And don&#8217;t forget to avoid Set::insert in production because of performance ;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cakebaker</title>
		<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/comment-page-1/#comment-44978</link>
		<dc:creator>cakebaker</dc:creator>
		<pubDate>Mon, 17 Dec 2007 17:15:19 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/#comment-44978</guid>
		<description>@Howard, Matt: Thanks for your comments!</description>
		<content:encoded><![CDATA[<p>@Howard, Matt: Thanks for your comments!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Matt</title>
		<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/comment-page-1/#comment-44918</link>
		<dc:creator>Matt</dc:creator>
		<pubDate>Mon, 17 Dec 2007 13:19:24 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/#comment-44918</guid>
		<description>The mixed approach is great! 

Great way of improving code readability!

I like all these insights very much.

Thanks!</description>
		<content:encoded><![CDATA[<p>The mixed approach is great! </p>
<p>Great way of improving code readability!</p>
<p>I like all these insights very much.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Howard</title>
		<link>http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/comment-page-1/#comment-44897</link>
		<dc:creator>Howard</dc:creator>
		<pubDate>Mon, 17 Dec 2007 12:02:18 +0000</pubDate>
		<guid isPermaLink="false">http://cakebaker.42dh.com/2007/12/17/an-alternative-way-to-create-arrays/#comment-44897</guid>
		<description>Brilliant &amp; simple, but I&#039;d never have noticed it without this post. Will beautify several horrible array constructions (findAll pivots and transformations not able to be done in the SQL) in a couple of my controller actions.

Enjoy reading your blog thru google reader, keep them coming</description>
		<content:encoded><![CDATA[<p>Brilliant &amp; simple, but I&#8217;d never have noticed it without this post. Will beautify several horrible array constructions (findAll pivots and transformations not able to be done in the SQL) in a couple of my controller actions.</p>
<p>Enjoy reading your blog thru google reader, keep them coming</p>
]]></content:encoded>
	</item>
</channel>
</rss>
