Sorry,

I should have said... "How would I iterate over these arrays using foreach"

-----Original Message-----
From: Liss, Mike [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 16, 2003 8:33 AM
To: [EMAIL PROTECTED]
Subject: multi-dimensional array foreach loop...


Ok,
 
I think I am beginning to see the light...
but I am still in the dark on this one...
 
How would I iterate over these arrays?
 
$MyArray[0][0][0] = "A 1";
$MyArray[0][1][0] = "comment 1";
 
$MyArray[0][0][1] = "A 2";
$MyArray[0][1][1] = "Comment 2";
 
$MyArray[1][0][0] = "B 1";
$MyArray[1][1][0] = "comment 1";
 
$MyArray[1][0][1] = "B 2";
$MyArray[1][1][1] = "Comment 2";
 
 
for example I could do this:
 
for( $i=0; $i<$n; $i++ )
{
    for( $j=0; $j<$m; $j++ )
    {
        for( $k=0; $k<$p; $k++ )
        {
            print " $MyArray[ $i ][ $j ][ $p ] \n" ;
        }
    }
}
 
But the problem with that is I don't know what n, m, and p are going to
be...
 
 
Thanks
Mike

Reply via email to