<?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>PHP Architect blog &#187; recursive</title>
	<atom:link href="http://www.php-architect.com/blog/tag/recursive/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.php-architect.com/blog</link>
	<description>me, myself, and my code</description>
	<lastBuildDate>Wed, 14 Sep 2011 12:50:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>List array Recursively in PHP</title>
		<link>http://www.php-architect.com/blog/2009/02/17/list-array-recursively-in-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=list-array-recursively-in-php</link>
		<comments>http://www.php-architect.com/blog/2009/02/17/list-array-recursively-in-php/#comments</comments>
		<pubDate>Wed, 18 Feb 2009 03:53:59 +0000</pubDate>
		<dc:creator>aibrahim</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Web Design]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[recursive]]></category>
		<guid isPermaLink="false">http://www.php-architect.com/blog/?p=241</guid>
		<description><![CDATA[<a href="http://www.php-architect.com/blog/2009/02/17/list-array-recursively-in-php/" title="List array Recursively in PHP"></a>Code : function listArrayRecursive&#40;$array_name, $ident = 0&#41;&#123; if &#40;is_array&#40;$array_name&#41;&#41;&#123; foreach &#40;$array_name as $k =&#62; $v&#41;&#123; if &#40;is_array&#40;$v&#41;&#41;&#123; for &#40;$i=0; $i &#60; $ident * 10; $i++&#41;&#123; echo &#34;&#38;nbsp;&#34;; &#125; echo $k . &#34; : &#34; . &#34;&#60;br&#62;&#34;; listArrayRecursive&#40;$v, $ident + 1&#41;; &#8230;<p class="read-more"><a href="http://www.php-architect.com/blog/2009/02/17/list-array-recursively-in-php/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://www.php-architect.com/blog/2009/02/17/list-array-recursively-in-php/" title="List array Recursively in PHP"></a><iframe src="http://www.facebook.com/plugins/like.php?href=http://www.php-architect.com/blog/2009/02/17/list-array-recursively-in-php/&amp;layout=standard&amp;show_faces=1&amp;width=450&amp;action=like&amp;colorscheme=light&amp;font=" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:450px; height:25px"></iframe><p>Code :</p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">function</span> listArrayRecursive<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_name</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ident</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_name</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$array_name</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">=&gt;</span> <span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">is_array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$ident</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&amp;nbsp;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; : &quot;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
				listArrayRecursive<span style="color: #009900;">&#40;</span><span style="color: #000088;">$v</span><span style="color: #339933;">,</span> <span style="color: #000088;">$ident</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
				<span style="color: #b1b100;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span> <span style="color: #339933;">&lt;</span> <span style="color: #000088;">$ident</span> <span style="color: #339933;">*</span> <span style="color: #cc66cc;">10</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;&amp;nbsp;&quot;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
				<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$k</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; : &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$v</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
		<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Variable = &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$array_name</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>
<p>Usage :</p>
<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$ages</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
				<span style="color: #0000ff;">&quot;ahmed&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;25&quot;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">&quot;mohamed&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;35&quot;</span><span style="color: #339933;">,</span>
				<span style="color: #0000ff;">&quot;group&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;omar&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;15&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;abdalla&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;20&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;sub group&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;john&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;10&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;peter&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;20&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
listArrayRecursive<span style="color: #009900;">&#40;</span><span style="color: #000088;">$ages</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>
<p>Output will be printed array in indented way.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.php-architect.com/blog/2009/02/17/list-array-recursively-in-php/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>

