Forum : How can I display values in a two dimensional array?
Brief description  about Online courses   join in Online courses
View Balu  Prasad 's Profile

How can I display values in a two dimensional array?

hi,

How can I display values in a two dimensional array?
Asked by Balu Prasad | Nov 27, 2009 |  Reply now
Replies (1)
View teacher siliconindia 's Profile
Hi balu,

You were along the right lines with the foreach command - you simply need to nest a foreach within another foreach, like this:

<?php
$myarray = array();
$myarray[0] = array(1,2,3,4);
$myarray[1] = array(5,6,7,8);
//
foreach($myarray as $v) {
foreach($v as $myv) {
echo "$myv<br>";
}
}
//prints 1 through 8 on screen
?>
Nov 27, 2009