<?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>Evolution Systems &#187; print_r</title>
	<atom:link href="http://evolution-systems.co.uk/tag/print_r/feed/" rel="self" type="application/rss+xml" />
	<link>http://evolution-systems.co.uk</link>
	<description>Web Development, Software Development and Linux Consultancy services</description>
	<lastBuildDate>Fri, 08 Aug 2025 09:18:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>https://wordpress.org/?v=4.1.42</generator>
	<item>
		<title>Nice PHP print_r Formatted Table Function</title>
		<link>http://evolution-systems.co.uk/2012/01/16/nice-php-print_r-formatted-table-function/</link>
		<comments>http://evolution-systems.co.uk/2012/01/16/nice-php-print_r-formatted-table-function/#comments</comments>
		<pubDate>Mon, 16 Jan 2012 18:58:46 +0000</pubDate>
		<dc:creator><![CDATA[Matthew Jakeman]]></dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[PHP Functions]]></category>
		<category><![CDATA[print_r]]></category>

		<guid isPermaLink="false">http://evolution-systems.co.uk/?p=654</guid>
		<description><![CDATA[Whilst looking through php.net I stumbled across the following function that will print out an array in a nicely formatted table. When dealing with lots of nested array something like this makes it much easier to see all of the data contained within an array.]]></description>
				<content:encoded><![CDATA[<p>Whilst looking through php.net I stumbled across the following function that will print out an array in a nicely formatted table. When dealing with lots of nested array something like this makes it much easier to see all of the data contained within an array.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
 function print_nice($elem,$max_level=10,$print_nice_stack=array()){
 if(is_array($elem) || is_object($elem)){
 if(in_array(&amp;$elem,$print_nice_stack,true)){
 echo &quot;&lt;font color=red&gt;RECURSION&lt;/font&gt;&quot;;
 return;
 }
 $print_nice_stack[]=&amp;$elem;
 if($max_level&lt;1){
 echo &quot;&lt;font color=red&gt;nivel maximo alcanzado&lt;/font&gt;&quot;;
 return;
 }
 $max_level--;
 echo &quot;&lt;table border=1 cellspacing=0 cellpadding=3 width=100%&gt;&quot;;
 if(is_array($elem)){
 echo '&lt;tr&gt;&lt;td colspan=2  style=&quot;background-color:#333333;&quot;&gt;&lt;strong&gt;&lt;font  color=white&gt;ARRAY&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;';
 }else{
 echo '&lt;tr&gt;&lt;td colspan=2 style=&quot;background-color:#333333;&quot;&gt;&lt;strong&gt;';
 echo '&lt;font color=white&gt;OBJECT Type: '.get_class($elem).'&lt;/font&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;';
 }
 $color=0;
 foreach($elem as $k =&gt; $v){
 if($max_level%2){
 $rgb=($color++%2)?&quot;#888888&quot;:&quot;#BBBBBB&quot;;
 }else{
 $rgb=($color++%2)?&quot;#8888BB&quot;:&quot;#BBBBFF&quot;;
 }
 echo '&lt;tr&gt;&lt;td valign=&quot;top&quot; style=&quot;width:40px;background-color:'.$rgb.';&quot;&gt;';
 echo '&lt;strong&gt;'.$k.&quot;&lt;/strong&gt;&lt;/td&gt;&lt;td&gt;&quot;;
 print_nice($v,$max_level,$print_nice_stack);
 echo &quot;&lt;/td&gt;&lt;/tr&gt;&quot;;
 }
 echo &quot;&lt;/table&gt;&quot;;
 return;
 }
 if($elem === null){
 echo &quot;&lt;font color=green&gt;NULL&lt;/font&gt;&quot;;
 }elseif($elem === 0){
 echo &quot;0&quot;;
 }elseif($elem === true){
 echo &quot;&lt;font color=green&gt;TRUE&lt;/font&gt;&quot;;
 }elseif($elem === false){
 echo &quot;&lt;font color=green&gt;FALSE&lt;/font&gt;&quot;;
 }elseif($elem === &quot;&quot;){
 echo &quot;&lt;font color=green&gt;EMPTY STRING&lt;/font&gt;&quot;;
 }else{
 echo str_replace(&quot;\n&quot;,&quot;&lt;strong&gt;&lt;font color=red&gt;*&lt;/font&gt;&lt;/strong&gt;&lt;br&gt;\n&quot;,$elem);
 }
 }
 ?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://evolution-systems.co.uk/2012/01/16/nice-php-print_r-formatted-table-function/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
