SQL PHP HTML ASP JavaScript articles and free scripts to download

Multidimensional array

This is know as array of array or multidimensional array. We have used user a two dimensional array . Here is the example of creating an array

$a= array(
array("path"=>"php_tutorial",
"section"=>"php"
),
array("path"=>"sql_tutorial",
"section"=>"sql"
),
array("path"=>"javascript_tutorial",
"section"=>"js"
),
array("path"=>"html_tutorial",
"section"=>"html"
),

);

Now to display the elements of this array we can use like this.

$max=sizeof($a);
for($i=0; $i<$max; $i++) {

while (list ($key, $val) = each ($a[$i])) {
echo "$key -> $val <br>";
} // inner array while loop

} // outer array for loop

The output is here

path -> php_tutorial
section -> php
path -> sql_tutorial
section -> sql
path -> javascript_tutorial
section -> js
path -> html_tutorial
section -> html

To display individual element

echo $a[2]['path'];

Output is here

javascript_tutorial


Google+
Post Comment This is for short comments only. Use the forum for more discussions.
Name
Email( not to be displayed)Privacy Policy
1+2=This is to prevent automatic submission by spammers. Please enter the result of the sum as asked



Join Our Email List
Email:  
For Email Newsletters you can trust
HTML . MySQL. PHP. JavaScript. ASP. Photoshop. Articles. FORUM Contact us

©2000-2014 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer