<?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 Magic Book - Free PHP Scripts, Tutorials and Downloads &#187; Arrays</title>
	<atom:link href="http://www.phpmagicbook.com/category/arrays/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.phpmagicbook.com</link>
	<description>PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips</description>
	<lastBuildDate>Tue, 15 Jun 2010 13:22:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Get Data As An Array &#8211; Download PHP Example</title>
		<link>http://www.phpmagicbook.com/get-data-as-an-array-download-php-example/</link>
		<comments>http://www.phpmagicbook.com/get-data-as-an-array-download-php-example/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 18:38:22 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Arrays]]></category>
		<category><![CDATA[For Loop]]></category>
		<category><![CDATA[Scripts]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[Loops]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=167</guid>
		<description><![CDATA[Array &#038; Loop Example Suppose we have a form and we want from user to select from a list of check boxes and check his favorite choices, post that data as an array and we want to display that data by calling array and arranging it in a loop. Then for this purpose consider following [...]<p><a href="http://www.phpmagicbook.com/get-data-as-an-array-download-php-example/">Get Data As An Array &#8211; Download PHP Example</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<h4>Array &#038; Loop Example</h4>
<p>Suppose we have a form and we want from user to select from a list of check boxes and check his favorite choices, post that data as an array and we want to display that data by calling array and arranging it in a loop. Then for this purpose consider following example.</p>
<p><span id="more-237"></span></p>
<h4>Form Code</h4>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;p&gt;Arrays example&lt;/p&gt;
&lt;p&gt;Check your favorite Movies:
&lt;/p&gt;
&lt;form action=&quot;nextpagename.php&quot; method=&quot;post&quot; name=&quot;array-form&quot; id=&quot;array-form&quot;&gt;
  &lt;p&gt;
    &lt;input name=&quot;pick[]&quot; type=&quot;checkbox&quot; value=&quot;Harry Potter&quot;&gt;
    Harry Potter&lt;br /&gt;
    &lt;input name=&quot;pick[]&quot; type=&quot;checkbox&quot; value=&quot;The Hobbit&quot;&gt;
    The Hobbit&lt;br /&gt;
    &lt;input name=&quot;pick[]&quot; type=&quot;checkbox&quot; value=&quot;Lord Of Rings&quot;&gt;
    Lord Of Rings&lt;br /&gt;
    &lt;input name=&quot;pick[]&quot; type=&quot;checkbox&quot; value=&quot;Matrix&quot;&gt;
    Matrix&lt;br /&gt;
    &lt;input name=&quot;pick[]&quot; type=&quot;checkbox&quot; value=&quot;Happy Feet&quot;&gt;
    Happy Feet&lt;br /&gt;
    &lt;input name=&quot;pick[]&quot; type=&quot;checkbox&quot; value=&quot;The Hell Boy&quot;&gt;
    The Hell Boy&lt;br /&gt;
    &lt;input name=&quot;pick[]&quot; type=&quot;checkbox&quot; value=&quot;Hulk&quot;&gt;
    Hulk&lt;/p&gt;
  &lt;p&gt;
    &lt;label&gt;
    &lt;input type=&quot;submit&quot; name=&quot;button&quot; id=&quot;button&quot; value=&quot;Submit&quot;&gt;
    &lt;/label&gt;
&lt;/p&gt;
&lt;/form&gt;</pre></div></div>

<h4>PHP Code &#8211; Retrieve Data From Array and Display It Through A Loop</h4>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</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>count<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pick'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</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: #000088;">$displaydata</span><span style="color: #339933;">=</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'pick'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;<span style="color: #006699; font-weight: bold;">$displaydata</span>&quot;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>In the above example we have collected the data from check boxes in form of arrays named as <strong>pick[]</strong> and we have sent it to another PHP page where it is displayed through a for loop.</p>
<p><a href='http://www.phpmagicbook.com/wp-content/uploads/2008/06/array-example.rar' class="download">PHP Arrays Example Download</a></p>
<p><a href="http://www.phpmagicbook.com/get-data-as-an-array-download-php-example/">Get Data As An Array &#8211; Download PHP Example</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/php-for-loop/" title="PHP For Loop">PHP For Loop</a></li><li><a href="http://www.phpmagicbook.com/php-arrays/" title="PHP Arrays">PHP Arrays</a></li><li><a href="http://www.phpmagicbook.com/php-for-each-loop/" title="PHP ForEach Loop">PHP ForEach Loop</a></li><li><a href="http://www.phpmagicbook.com/php-do-while-loop/" title="PHP Do While Loop">PHP Do While Loop</a></li><li><a href="http://www.phpmagicbook.com/php-while-loop/" title="PHP While Loop">PHP While Loop</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/get-data-as-an-array-download-php-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Arrays</title>
		<link>http://www.phpmagicbook.com/php-arrays/</link>
		<comments>http://www.phpmagicbook.com/php-arrays/#comments</comments>
		<pubDate>Sun, 22 Jun 2008 18:14:07 +0000</pubDate>
		<dc:creator>Hiroshi</dc:creator>
				<category><![CDATA[Arrays]]></category>
		<category><![CDATA[PHP Basics]]></category>
		<category><![CDATA[basics]]></category>

		<guid isPermaLink="false">http://www.phpmagicbook.com/?p=166</guid>
		<description><![CDATA[An array is a data structure that stores one or more values in a single value. In more detail &#8216;An array&#8217; in PHP is actually an ordered map. A map is a type that maps values to keys. This type is optimized in several ways, so you can use it as a real array, or [...]<p><a href="http://www.phpmagicbook.com/php-arrays/">PHP Arrays</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
]]></description>
			<content:encoded><![CDATA[<p>An array is a data structure that stores one or more values in a single value. In more detail &#8216;An array&#8217; in PHP is actually an ordered map. A map is a type that maps values to keys. This type is optimized in several ways, so you can use it as a real array, or a list (vector), hashtable (which is an implementation of a map), dictionary, collection, stack, queue and probably more. Because you can have another PHP array as a value, you can also quite easily simulate trees.</p>
<p>An array can be created by the array() language-construct. It takes a certain number of comma-separated key => value pairs.</p>
<p><span id="more-236"></span></p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$my_array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;somearray&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">13</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">9</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;a&quot;</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">42</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$my_array</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;somearray&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>    <span style="color: #666666; font-style: italic;">// Output: 5</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$my_array</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;somearray&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">13</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>   <span style="color: #666666; font-style: italic;">// Output: 9</span>
<span style="color: #b1b100;">echo</span> <span style="color: #000088;">$my_array</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;somearray&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">&quot;a&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>  <span style="color: #666666; font-style: italic;">// Output: 42</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$programming_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;PHP&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$programming_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ASP&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$programming_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;AJAX&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$programming_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">3</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;JSP&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">&quot;Two of most valuable programming resources are &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$programming_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; &amp; &quot;</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$programming_array</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">2</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Output:</span>
<span style="color: #666666; font-style: italic;">// Two of most valuable programming resources are PHP &amp; AJAX</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><a href="http://www.phpmagicbook.com/php-arrays/">PHP Arrays</a> is a post from: <a href="http://www.phpmagicbook.com">PHP Magic Book - Free PHP Scripts, Tutorials and Downloads</a></p>
<h3  class="related_post_title">Related Posts</h3><ul class="related_post"><li><a href="http://www.phpmagicbook.com/find-page-url-php/" title="Find Page URL With PHP &#8211; File Path">Find Page URL With PHP &#8211; File Path</a></li><li><a href="http://www.phpmagicbook.com/php-string-case-capitalization/" title="PHP &#8211; String Case &#8211; Capitalization">PHP &#8211; String Case &#8211; Capitalization</a></li><li><a href="http://www.phpmagicbook.com/php-post-and-get/" title="PHP Post And Get">PHP Post And Get</a></li><li><a href="http://www.phpmagicbook.com/get-data-as-an-array-download-php-example/" title="Get Data As An Array &#8211; Download PHP Example">Get Data As An Array &#8211; Download PHP Example</a></li><li><a href="http://www.phpmagicbook.com/php-strings/" title="PHP Strings">PHP Strings</a></li><li><a href="http://www.phpmagicbook.com/local-and-glob-scope/" title="Local And Global Variable Scope in PHP">Local And Global Variable Scope in PHP</a></li><li><a href="http://www.phpmagicbook.com/php-logical-operators/" title="PHP Logical Operators">PHP Logical Operators</a></li><li><a href="http://www.phpmagicbook.com/php-functions/" title="PHP Functions">PHP Functions</a></li><li><a href="http://www.phpmagicbook.com/php-for-each-loop/" title="PHP ForEach Loop">PHP ForEach Loop</a></li><li><a href="http://www.phpmagicbook.com/php-do-while-loop/" title="PHP Do While Loop">PHP Do While Loop</a></li></ul>]]></content:encoded>
			<wfw:commentRss>http://www.phpmagicbook.com/php-arrays/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.847 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2010-07-30 16:30:36 -->
