<?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"
	>
<channel>
	<title>Comments on: Neat PHP Tricks: Casting Arrays to Objects</title>
	<atom:link href="http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/</link>
	<description>Look! Bunnies!</description>
	<pubDate>Wed, 07 Jan 2009 14:06:10 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.6.1</generator>
		<item>
		<title>By: Recent Links Tagged With "arrays" - JabberTags</title>
		<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/#comment-4847</link>
		<dc:creator>Recent Links Tagged With "arrays" - JabberTags</dc:creator>
		<pubDate>Sun, 19 Oct 2008 05:19:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.otton.org/?p=210#comment-4847</guid>
		<description>[...] 19-10-2008   Passing Arrays Between Javascript And Php Saved by thetrevistabomb on Sat 18-10-2008   Neat PHP tricks: Casting Arrays to Objects Saved by royalchinook on Fri 17-10-2008   Primitive Data Types, Arrays, Loops, and Conditions: Part [...]</description>
		<content:encoded><![CDATA[<p>[...] 19-10-2008   Passing Arrays Between Javascript And Php Saved by thetrevistabomb on Sat 18-10-2008   Neat PHP tricks: Casting Arrays to Objects Saved by royalchinook on Fri 17-10-2008   Primitive Data Types, Arrays, Loops, and Conditions: Part [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: [PHP] 將 array 強制轉型為 object &#171; Oceanic &#124; 人生海海</title>
		<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/#comment-4633</link>
		<dc:creator>[PHP] 將 array 強制轉型為 object &#171; Oceanic &#124; 人生海海</dc:creator>
		<pubDate>Sat, 06 Sep 2008 03:50:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.otton.org/?p=210#comment-4633</guid>
		<description>[...] Neat PHP Tricks: Casting Arrays to Objects, 我覺得這篇可以稍微看一下。 [...]</description>
		<content:encoded><![CDATA[<p>[...] Neat PHP Tricks: Casting Arrays to Objects, 我覺得這篇可以稍微看一下。 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/#comment-4473</link>
		<dc:creator>david</dc:creator>
		<pubDate>Fri, 15 Aug 2008 14:48:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.otton.org/?p=210#comment-4473</guid>
		<description>Erick: $obj is still an object when you reach the loop. Try this:

&lt;code&gt;
$obj = (array)$obj;
var_dump($obj);
&lt;/code&gt;

(love your site design, BTW).</description>
		<content:encoded><![CDATA[<p>Erick: $obj is still an object when you reach the loop. Try this:</p>
<p><code><br />
$obj = (array)$obj;<br />
var_dump($obj);<br />
</code></p>
<p>(love your site design, BTW).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Erick</title>
		<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/#comment-4472</link>
		<dc:creator>Erick</dc:creator>
		<pubDate>Fri, 15 Aug 2008 14:41:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.otton.org/?p=210#comment-4472</guid>
		<description>It seems that the private variable is there in the array yes but it seems that it is invisible.

Try this:
class obj
{
public $var1 = 1;
public $var2 = 2;
private $var3 = 3;
}

$obj = new obj();

var_dump((array)$obj);

foreach($obj as $i)
echo $i;

It will ouput: 
array(3) {
  ["var1"]=&#62;
  int(1)
  ["var2"]=&#62;
  int(2)
  ["�obj�var3"]=&#62;
  int(3)
}
12</description>
		<content:encoded><![CDATA[<p>It seems that the private variable is there in the array yes but it seems that it is invisible.</p>
<p>Try this:<br />
class obj<br />
{<br />
public $var1 = 1;<br />
public $var2 = 2;<br />
private $var3 = 3;<br />
}</p>
<p>$obj = new obj();</p>
<p>var_dump((array)$obj);</p>
<p>foreach($obj as $i)<br />
echo $i;</p>
<p>It will ouput:<br />
array(3) {<br />
  ["var1"]=&gt;<br />
  int(1)<br />
  ["var2"]=&gt;<br />
  int(2)<br />
  ["�obj�var3"]=&gt;<br />
  int(3)<br />
}<br />
12</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave</title>
		<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/#comment-4471</link>
		<dc:creator>Dave</dc:creator>
		<pubDate>Fri, 15 Aug 2008 13:56:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.otton.org/?p=210#comment-4471</guid>
		<description>What about multi-dimensional arrays?</description>
		<content:encoded><![CDATA[<p>What about multi-dimensional arrays?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jonathan Franzone</title>
		<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/#comment-4470</link>
		<dc:creator>Jonathan Franzone</dc:creator>
		<pubDate>Fri, 15 Aug 2008 13:55:35 +0000</pubDate>
		<guid isPermaLink="false">http://www.otton.org/?p=210#comment-4470</guid>
		<description>Nice tip! I didn't actually know you could just do a cast like that.</description>
		<content:encoded><![CDATA[<p>Nice tip! I didn&#8217;t actually know you could just do a cast like that.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: david</title>
		<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/#comment-4468</link>
		<dc:creator>david</dc:creator>
		<pubDate>Fri, 15 Aug 2008 09:39:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.otton.org/?p=210#comment-4468</guid>
		<description>Well, &lt;code&gt;ArrayObject&lt;/code&gt; does get you &lt;a href="http://uk2.php.net/manual/en/class.arrayobject.php" rel="nofollow"&gt;neat stuff&lt;/a&gt; like &lt;code&gt;Traversable&lt;/code&gt; and &lt;code&gt;Countable&lt;/code&gt;, but if you don't need them, casting to &lt;code&gt;stdClass&lt;/code&gt; is roughly twice as fast.</description>
		<content:encoded><![CDATA[<p>Well, <code>ArrayObject</code> does get you <a href="http://uk2.php.net/manual/en/class.arrayobject.php">neat stuff</a> like <code>Traversable</code> and <code>Countable</code>, but if you don&#8217;t need them, casting to <code>stdClass</code> is roughly twice as fast.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ivan Iordanov</title>
		<link>http://www.otton.org/2008/08/14/neat-php-tricks-casting-arrays-to-objects/#comment-4467</link>
		<dc:creator>Ivan Iordanov</dc:creator>
		<pubDate>Fri, 15 Aug 2008 07:54:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.otton.org/?p=210#comment-4467</guid>
		<description>Why not to use $obj = new ArrayObject($array);</description>
		<content:encoded><![CDATA[<p>Why not to use $obj = new ArrayObject($array);</p>
]]></content:encoded>
	</item>
</channel>
</rss>
