<?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 Interview Questions and answers&#187; arrays archives  &#8211; interview questions and answers</title>
	<atom:link href="http://www.phpinterviewquestions.com/tag/arrays/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpinterviewquestions.com</link>
	<description>Prepare for your next php based interview with high confidence</description>
	<lastBuildDate>Mon, 26 Sep 2011 08:37:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>sorting arrays</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/sorting-arrays-2/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/sorting-arrays-2/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 00:54:39 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Advanced level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=91</guid>
		<description><![CDATA[Both sort() and asort() is used to sort values in ascending order.To sort them in descending order what are the functions that we can use?
rsort() &#8211; Where it resets key associations as well.
arsort() &#8211; Where it sorts in descending order, while keeping the key associations as well.




]]></description>
			<content:encoded><![CDATA[<p>Both sort() and asort() is used to sort values in ascending order.To sort them in descending order what are the functions that we can use?</p>
<p>rsort() &#8211; Where it resets key associations as well.<br />
arsort() &#8211; Where it sorts in descending order, while keeping the key associations as well.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 468x15, created 4/16/10 */
google_ad_slot = "1994287074";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/sorting-arrays-2/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Array sorting</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/array-sorting/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/array-sorting/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 00:44:51 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Advanced level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=87</guid>
		<description><![CDATA[What is the difference between sort() and asort()?
The main difference is that sort() will sort an array without concerning it&#8217;s key associations while asort() will maintain it&#8217;s key association as well.




]]></description>
			<content:encoded><![CDATA[<p>What is the difference between sort() and asort()?</p>
<p>The main difference is that sort() will sort an array without concerning it&#8217;s key associations while asort() will maintain it&#8217;s key association as well.</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 468x15, created 4/16/10 */
google_ad_slot = "1994287074";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/array-sorting/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Sorting arrays</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/sorting-arrays/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/sorting-arrays/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 00:38:23 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Advanced level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[sort]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=85</guid>
		<description><![CDATA[What is the best way to sort an array by maintaining it&#8217;s key associations as well?
$array = array(&#8216;a&#8217;=>&#8217;foo&#8217;,'b&#8217;=>&#8217;bar&#8217;,'c&#8217;=>&#8217;baz&#8217;);
asort($array);
print_r($array);
Array
(
    [b] => bar
     => baz
    [a] => foo
)




]]></description>
			<content:encoded><![CDATA[<p>What is the best way to sort an array by maintaining it&#8217;s key associations as well?</p>
<p>$array = array(&#8216;a&#8217;=>&#8217;foo&#8217;,'b&#8217;=>&#8217;bar&#8217;,'c&#8217;=>&#8217;baz&#8217;);<br />
asort($array);<br />
print_r($array);</p>
<p>Array<br />
(<br />
    [b] => bar<br />
     => baz<br />
    [a] => foo<br />
)</p>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 468x15, created 4/16/10 */
google_ad_slot = "1994287074";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/sorting-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Passive Iteration</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/passive-iteration/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/passive-iteration/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 10:49:29 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Expert level]]></category>
		<category><![CDATA[PHP Questions]]></category>
		<category><![CDATA[arrays]]></category>
		<category><![CDATA[array_combine]]></category>
		<category><![CDATA[array_walk]]></category>
		<category><![CDATA[array_walk_recursive]]></category>
		<category><![CDATA[Iteration]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/?p=49</guid>
		<description><![CDATA[What will be the out put of the following code snippet ?
&#60;?php
function setcase(&#38;$value, &#38;$key){
$value = strtoupper($value);
}
$type = array('internal','external');
$format[] = array('rss','html','xml');
$format[] = array('csv','jason');
$map = array_combine($type, $format);
array_walk_recursive($map, 'setcase');
print_r($map);
?&#62;
Only scalar values will be converted to upper cases. &#8216; internal&#8217; and &#8216;external&#8217; are not passed into the user defined function.
Array
(
    [internal] =&#38;gt; Array
    [...]]]></description>
			<content:encoded><![CDATA[<p>What will be the out put of the following code snippet ?</p>
<pre class="brush: php;">&lt;?php
function setcase(&amp;$value, &amp;$key){
$value = strtoupper($value);
}
$type = array('internal','external');
$format[] = array('rss','html','xml');
$format[] = array('csv','jason');
$map = array_combine($type, $format);
array_walk_recursive($map, 'setcase');
print_r($map);
?&gt;</pre>
<p>Only scalar values will be converted to upper cases. &#8216; internal&#8217; and &#8216;external&#8217; are not passed into the user defined function.</p>
<pre class="brush: php;">Array
(
    [internal] =&amp;gt; Array
        (
            [0] =&amp;gt; RSS
            [1] =&amp;gt; HTML
            [2] =&amp;gt; XML
        )

    [external] =&amp;gt; Array
        (
            [0] =&amp;gt; CSV
            [1] =&amp;gt; JASON
        )

)
</pre>
<p><script type="text/javascript"><!--
google_ad_client = "pub-8695027799979044";
/* 468x15, created 4/16/10 */
google_ad_slot = "1994287074";
google_ad_width = 468;
google_ad_height = 15;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/passive-iteration/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Printing Arrays and objects</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/printing-arrays-and-objects/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/printing-arrays-and-objects/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Regular level]]></category>
		<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=8</guid>
		<description><![CDATA[What methods can be used to debug or print an array or object?
print_r() or var_dump()
]]></description>
			<content:encoded><![CDATA[<p>What methods can be used to debug or print an array or object?</p>
<p>print_r() or var_dump()</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/printing-arrays-and-objects/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Associative and enumerative arrays</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/associative-and-enumerative-arrays/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/associative-and-enumerative-arrays/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Regular level]]></category>
		<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=10</guid>
		<description><![CDATA[Does PHP support associative arrays?
Yes it does.
]]></description>
			<content:encoded><![CDATA[<p>Does PHP support associative arrays?</p>
<p>Yes it does.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/associative-and-enumerative-arrays/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Size of an array</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/size-of-an-array/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/size-of-an-array/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Regular level]]></category>
		<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=11</guid>
		<description><![CDATA[What are the methods to use to count an array?
count() or sizeof()
]]></description>
			<content:encoded><![CDATA[<p>What are the methods to use to count an array?</p>
<p>count() or sizeof()</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/size-of-an-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Existence of an array</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/existence-of-an-array/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/existence-of-an-array/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Regular level]]></category>
		<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=12</guid>
		<description><![CDATA[How to identify whether a variable contains an array?
is_array() function can be used.
]]></description>
			<content:encoded><![CDATA[<p>How to identify whether a variable contains an array?</p>
<p>is_array() function can be used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/existence-of-an-array/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Array elements</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/array-elements/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/array-elements/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Regular level]]></category>
		<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=13</guid>
		<description><![CDATA[What methods can be used to determine whether an array element exits or not?
array_key_exist or isset() methods can be used.
]]></description>
			<content:encoded><![CDATA[<p>What methods can be used to determine whether an array element exits or not?</p>
<p>array_key_exist or isset() methods can be used.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/array-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Array elements</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/array-elements-2/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/array-elements-2/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Regular level]]></category>
		<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=14</guid>
		<description><![CDATA[Which is the best way to determine of an array element&#8217;s existence?
array_key_exists()
It is because isset returns false even though if an array element is defined as a NULL.
]]></description>
			<content:encoded><![CDATA[<p>Which is the best way to determine of an array element&#8217;s existence?</p>
<p>array_key_exists()<br />
It is because isset returns false even though if an array element is defined as a NULL.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/array-elements-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Arrays</title>
		<link>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/arrays/</link>
		<comments>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/arrays/#comments</comments>
		<pubDate>Tue, 23 Feb 2010 05:19:03 +0000</pubDate>
		<dc:creator>Bart</dc:creator>
				<category><![CDATA[Regular level]]></category>
		<category><![CDATA[arrays]]></category>

		<guid isPermaLink="false">http://www.phpinterviewquestions.com/wordpress/?p=31</guid>
		<description><![CDATA[What is the difference between array_flip() and array_reverse()?
array_flip just flip the values of the array with its key values. But array_reverse actually reverse the order of the array&#8217;s elements, so that last one appears first.
]]></description>
			<content:encoded><![CDATA[<p>What is the difference between array_flip() and array_reverse()?</p>
<p>array_flip just flip the values of the array with its key values. But array_reverse actually reverse the order of the array&#8217;s elements, so that last one appears first.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.phpinterviewquestions.com/php-interview-questions/regular-level-php-interview-questions/arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

