Solved

# Iterate over variable sized two dimensional array?

Posted on 2010-08-12
214 Views
How can I iterate over a variable sized two dimensional array?

In this array, the first dimensional has size 7, but the second is of a variable size.

Array ( [0] => Array ( ) [1] => Array ( [0] => A ) [2] => Array ( [0] => B ) [3] => Array ( [0] => B [1] => A ) [4] => Array ( [0] => C ) [5] => Array ( [0] => C [1] => A ) [6] => Array ( [0] => C [1] => B ) [7] => Array ( [0] => C [1] => B [2] => A ) )
0
Question by:pillmill

LVL 59

Accepted Solution

Chris Bottomley earned 500 total points
ID: 33422063
lbound(array, 1) to ubound(array, 1) for the first dimension and
lbound(array, 2) to ubound(array, 2) for the second?

Chris
0

LVL 2

Expert Comment

ID: 33422129
try this

for ( \$i = 0 ; \$i < count(\$arr) ; \$i++ )
{
echo "<br>";
for ( \$j = 0 ; \$j < count(\$arr[\$i]) ; \$j++ )
{
echo \$arr[\$i][\$j] . " - ";
}

}
0

## Join & Write a Comment Already a member? Login.

This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

#### 744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

#### Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!