Php

How can we print array with in array using for-each loop – Three dimensional array

Google+ Pinterest LinkedIn Tumblr

A multidimensional array is an array containing one or more arrays.

Three-Dimensional array

For three dimensional array u have to use two for loop condition
find 0 indexed array value and then 0 indexed array value

<?php

$developedesks = array(
"Skills" => array
(
"php" => 80,
"css" => 85,
"html" => 80
),
"design" => array
(
"photoshop" => 70,
"flash" => 75,
"indesign" => 72
),
"framework" => array
(
"wordpress" => 85,
"drupal" => 75,
"joomla" => 70
)
);

$count = count($developedesks);
echo "$count<br/>";
foreach($developedesks  as $develop => $desks)
{

foreach($desks as $key =>$value)
{
echo "$develop &nbsp; $key &nbsp; $value<br/>";
}

}

?>

Explain

First foreach consider skill as $develop and php =>80 as $desks

Second For each consider $key as php and $ value as 80

so the $develop –> indexed as skill, $key–> indexed as php and $value indexed as 80

simple foreach concept worked

Output

Skills  php  80
Skills  css    85
Skills  html   80
design  photoshop 70
design  flash    75
design  indesign   72
framework wordpress 85
framework drupal   75
framework joomla   70

 

Similar like three dimensional array

Multidimensional Array concept in Php

A multidimensional array is an array containing one or more arrays.

Its is solution for to know how to handle a array with in array
Example
1.Two-dimensional array
2.Three-dimensional array

Here You can see Exaplaination

I'm Rajasekar - Web developer, Freelancer, Blogger and Owner of DeveloperDesks. From India lives in Bahrain. I love to do coding, Creating websites and trying different with code and designs. You Can Hire Me