<?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>0plus1 Blog &#187; print_r</title>
	<atom:link href="http://0plus1.com/blog/tag/print_r/feed/" rel="self" type="application/rss+xml" />
	<link>http://0plus1.com/blog</link>
	<description>Code snippets and programming resources</description>
	<lastBuildDate>Sat, 15 Jan 2011 15:09:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.4</generator>
		<item>
		<title>print_r output beautifier</title>
		<link>http://0plus1.com/blog/2009/05/print_r-output-beautifier/</link>
		<comments>http://0plus1.com/blog/2009/05/print_r-output-beautifier/#comments</comments>
		<pubDate>Wed, 13 May 2009 15:42:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Code Snippets]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[print_r]]></category>

		<guid isPermaLink="false">http://0plus1.com/blog/?p=9</guid>
		<description><![CDATA[Today I wrote a script that needed to manipulate several multidimensional arrays, some of them pretty deep. The standard php function print_r is an hellish mess, browsing through the marvellous php.net documentation I&#8217;ve found several examples to beautify the output of print_r (just to give credit: &#8220;Bob&#8221; and &#8220;Everett&#8221; were my inspiration) since no one [...]]]></description>
			<content:encoded><![CDATA[<p>Today I wrote a script that needed to manipulate several multidimensional arrays, some of them pretty deep.</p>
<p>The standard php function print_r is an hellish mess, browsing through the marvellous php.net documentation I&#8217;ve found several examples to beautify the output of print_r (just to give credit: &#8220;Bob&#8221; and &#8220;Everett&#8221; were my inspiration) since no one actually did it the way I wanted I made a custom one myself:</p>
<pre class="brush: php; title: ;">
function print_rr($array){
    foreach($array as $key=&gt;$value){
       if(is_array($value)){
          $id = md5(rand());
          echo '[&lt;a href=&quot;#&quot; onclick=&quot;return expandParent(\''.$id.'\')&quot;&gt;'.$key.'&lt;/a&gt;]&lt;br /&gt;';
          echo '&lt;div id=&quot;'.$id.'&quot; style=&quot;display:none;margin:10px;border-left:1px solid; padding-left:5px;&quot;&gt;';
          print_rr($value, $count);
          echo '&lt;/div&gt;';
       } else {
       echo &quot;&lt;b&gt;$key&lt;/b&gt;: &quot;.$value.&quot;&lt;br /&gt;&quot;;
       }
    }
echo '&lt;script language=&quot;Javascript&quot;&gt;
function expandParent(id){toggle=&quot;block&quot;;if(document.getElementById(id).style.display==&quot;block&quot;){toggle=&quot;none&quot;}document.getElementById(id).style.display=toggle};
&lt;/script&gt;';
}
</pre>
<p>Feel free to use it anyway you like it.</p>
]]></content:encoded>
			<wfw:commentRss>http://0plus1.com/blog/2009/05/print_r-output-beautifier/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

