
For Loop with Multidimensional Numeric Array:-
Multidimensional Array means one or more arrays have multple array values access. It can store numbers, string multiple array uses of Nested For Loop with Multidimensional Numeric Array.
ex:-
<?php | |
// For Loop with multi D Numeric Array | |
$a [0][0] = "value"; //column Multi D Array | |
$a [0][1] = "value1"; | |
$a [0][2] = "value2"; | |
$a [1][0] = "value3"; | |
$a [1][1] = "value4"; | |
$a [1][2] = "value5"; | |
$a [2][0] = "value6"; | |
$a [2][1] = "value7"; | |
$a [2][2] = "value8"; | |
for ($b = 0; $b < count($a); $b++) //numeric array starts with (0) | |
{ | |
echo "this is multi D sample <br>"; | |
for ($c = 0; $c < count($a [$b]); $c++) | |
{ | |
echo $a [$b][$c], "<br> "; | |
} | |
} echo "<br>"; | |
//second Type | |
$name = array ( | |
array ("ajay", "kumar", 10), //Row Multi D Array | |
array ("vijay", "kumar", 20), | |
array ("dhanjay", "kumar", 30) | |
); | |
for($e = 0; $e < count ($name); $e++) | |
{ | |
echo "this is multi D second type <br>"; | |
for($f = 0; $f < count ($name[$e]); $f++) | |
{ | |
echo $name[$e][$f], "<br>"; | |
} | |
} | |
?> |
Foreach Loop with Multidimensional Numeric:-
You can use Nested Foreach loop through Multidimensional arrays in multiple arrays for store index value as Nested For Loop in PHP.
ex:-
<?php | |
// Foreach Loop with Multi D Numeric | |
$a [0][0] = "value";//column Foreach Loop | |
$a [0][1] = "value1"; | |
$a [0][2] = "value2"; | |
$a [1][0] = "value3"; | |
$a [1][1] = "value4"; | |
$a [1][2] = "value5"; | |
$a [2][0] = "value6"; | |
$a [2][1] = "value7"; | |
$a [2][2] = "value8"; | |
foreach ($a as $b) //before $a value as $b | |
{ | |
foreach ($b as $c) | |
{ | |
echo $c , "<br>"; | |
} | |
} echo "<br>"; | |
//second example | |
$a [0][0] = "value"; | |
$a [0][1] = "value1"; | |
$a [0][2] = "value2"; | |
$a [1][0] = "value3"; | |
$a [1][1] = "value4"; | |
$a [1][2] = "value5"; | |
$a [2][0] = "value6"; | |
$a [2][1] = "value7"; | |
$a [2][2] = "value8"; | |
foreach ($a as $keys=> $b) //before $a value as $b | |
{ | |
foreach ($b as $key=> $c) | |
{ | |
echo $keys ," ", " ". $key , " " , $c, " "; | |
} | |
echo "<br>"; | |
} | |
?> |




Iβm a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND