<?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>Multidimensional Array Archives - Artificial Intelligence</title>
	<atom:link href="https://www.aiuniverse.xyz/tag/multidimensional-array/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.aiuniverse.xyz/tag/multidimensional-array/</link>
	<description>Exploring the universe of Intelligence</description>
	<lastBuildDate>Sat, 29 Apr 2023 13:00:55 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>PHP Arrays</title>
		<link>https://www.aiuniverse.xyz/php-arrays/</link>
					<comments>https://www.aiuniverse.xyz/php-arrays/#respond</comments>
		
		<dc:creator><![CDATA[Maruti Kr.]]></dc:creator>
		<pubDate>Sat, 29 Apr 2023 13:00:54 +0000</pubDate>
				<category><![CDATA[PHP Tutorials]]></category>
		<category><![CDATA[Associative Array]]></category>
		<category><![CDATA[Indexed Array]]></category>
		<category><![CDATA[Multidimensional Array]]></category>
		<category><![CDATA[types of array in PHP]]></category>
		<category><![CDATA[What is Array in PHP?]]></category>
		<category><![CDATA[What is Multidimensional Array]]></category>
		<guid isPermaLink="false">https://www.aiuniverse.xyz/?p=16626</guid>

					<description><![CDATA[<p>What is Array in PHP? There are 3 types of array in PHP. 1. Indexed Array: An indexed array is a type of array where each element <a class="read-more-link" href="https://www.aiuniverse.xyz/php-arrays/">Read More</a></p>
<p>The post <a href="https://www.aiuniverse.xyz/php-arrays/">PHP Arrays</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<h2 class="wp-block-heading">What is Array in PHP?</h2>



<div class="wp-block-media-text alignwide is-stacked-on-mobile" style="grid-template-columns:37% auto"><figure class="wp-block-media-text__media"><img fetchpriority="high" decoding="async" width="1024" height="683" src="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/phparraynew-1024x683.jpeg" alt="" class="wp-image-16629 size-full" srcset="https://www.aiuniverse.xyz/wp-content/uploads/2023/04/phparraynew-1024x683.jpeg 1024w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/phparraynew-300x200.jpeg 300w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/phparraynew-768x512.jpeg 768w, https://www.aiuniverse.xyz/wp-content/uploads/2023/04/phparraynew.jpeg 1080w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure><div class="wp-block-media-text__content">
<p>PHP arrays is a type of data structure that can hold multiple values of similar type in a single variable.</p>



<p>The Advantage of PHP Array is</p>



<ul class="wp-block-list">
<li>Less Code: We don&#8217;t need to define multiple variables.</li>



<li>Easy to traverse: By using single loop, we can traverse all the elements of an array.</li>



<li>Sorting: We can sort the elements of array.</li>
</ul>
</div></div>



<p>There are 3 types of array in PHP.</p>



<ol class="wp-block-list">
<li>Indexed Array</li>



<li>Associative Array</li>



<li>Multidimensional Array</li>
</ol>



<h2 class="wp-block-heading">1. Indexed Array:</h2>



<p>An indexed array is a type of array where each element is assigned a numeric index, starting from 0 and increasing by 1 for each subsequent element.</p>



<p>There are two ways to define indexed array:</p>



<p><strong>1st way:</strong></p>



<pre class="wp-block-code"><code>$animals= array("dog", "cat", "donkey", "monkey");</code></pre>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code>&lt;?php  
$animals=array("dog", "cat", "donkey", "monkey");
echo "animals are: $animals&#91;0], $animals&#91;1], $animals&#91;2] and $animals&#91;3]";  
?>  </code></pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-code"><code>animals are: dog, cat, donkey, monkey</code></pre>



<p><strong>2nd way:</strong></p>



<pre class="wp-block-code"><code>$animals &#91;0]="dog";  
$animals &#91;1]="cat";  
$animals &#91;2]="donkey";  
$animals &#91;3]="monkey";  </code></pre>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code>&lt;?php  
$animals &#91;0]="summer";  
$animals &#91;1]="winter";  
$animals &#91;2]="spring";  
$animals &#91;3]="autumn";  
echo "animals are: $animals &#91;0], $animals &#91;1], $animals &#91;2] and $animals &#91;3]";  
?>  </code></pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-code"><code>animals are: dog, cat, donkey, monkey</code></pre>



<h2 class="wp-block-heading">2. Associative Array:</h2>



<p>An associative array is a type of array where each element is assigned a unique key instead of a numeric index. This means that you can access the elements of an associative array using their keys instead of their positions.</p>



<p>There are two ways to define associative array:</p>



<p><strong>1st way:</strong></p>



<pre class="wp-block-code"><code>$salary=array("Ram"=>"550000","Shyam"=>"250000","Rahul"=>"200000");  </code></pre>



<p><strong>Example</strong>:</p>



<pre class="wp-block-code"><code>&lt;?php    
$salary=array("Ram "=>"550000","Shyam "=>"250000","Rahul"=>"200000");  
echo "Ram salary: ".$salary&#91;"Ram "]."&lt;br/>";  
echo "Shyam salary: ".$salary&#91;"Shyam"]."&lt;br/>";  
echo "Rahul salary: ".$salary&#91;"Rahul"]."&lt;br/>";  
?>    </code></pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-code"><code>Ram salary: 550000
Shyam salary: 250000
Rahul salary: 200000</code></pre>



<p><strong>2nd way:</strong></p>



<pre class="wp-block-code"><code>$salary&#91;"Ram"]="550000";  
$salary&#91;"Shyam"]="250000";  
$salary&#91;"Rahul"]="200000";  </code></pre>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code>&lt;?php    
$salary&#91;"Ram"]="550000";  
$salary&#91;"Shyam"]="250000";  
$salary&#91;"Rahul"]="200000";   
echo "Ram salary: ".$salary&#91;"Ram"]."&lt;br/>";  
echo "Shyam salary: ".$salary&#91;"Shyam"]."&lt;br/>";  
echo "Rahul salary: ".$salary&#91;"Rahul"]."&lt;br/>";  
?>    </code></pre>



<p><strong>Output:</strong></p>



<pre class="wp-block-code"><code>Ram salary: 550000
Shyam salary: 250000
Rahul salary: 200000</code></pre>



<h2 class="wp-block-heading">3. Multidimensional Arrays:</h2>



<p>A multidimensional array is an array that contains one or more arrays as its elements. Each array within the multidimensional array is known as a dimension, and can contain its own set of elements. This allows you to store complex data structures in a single variable.</p>



<p><strong>Example:</strong></p>



<pre class="wp-block-code"><code>&lt;?php
$cars = array (
  array("Volvo",22,18),
  array("BMW",15,13),
  array("Saab",5,2),
  array("Land Rover",17,15)
);
echo $cars&#91;0]&#91;0].": In stock: ".$cars&#91;0]&#91;1].", sold: ".$cars&#91;0]&#91;2].".&lt;br>";
?></code></pre>
<p>The post <a href="https://www.aiuniverse.xyz/php-arrays/">PHP Arrays</a> appeared first on <a href="https://www.aiuniverse.xyz">Artificial Intelligence</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.aiuniverse.xyz/php-arrays/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
