Thread: Arrays in PHP
View Single Post
Old Jan 11th, 2006, 8:33 PM   #1
MrMan9879
Programmer
 
MrMan9879's Avatar
 
Join Date: Sep 2005
Location: Nanaimo, BC, Canada
Posts: 95
Rep Power: 0 MrMan9879 is an unknown quantity at this point
Send a message via MSN to MrMan9879
Arrays in PHP

Just as a question... how often do you think a PHP programmer will use arrays? I am learning about them right now, and multidimensional arrays seem a bit confusing... There's this line of code in my book that I'm pretty sure explains how to get the content out of three-dimensional arrays with a for loop that I don't really understand how it works... I don't really understand what it means by layer and columns.

[PHP]for ( $layer = 0; $layer < 3; $layer++ )
{
echo "Layer $layer<br />";
for ( $row = 0; $row < 3; $row++ )
{
for ( $column = 0; $column < 3; $column++ )
{
echo '|'.$categories[$layer][$row][$column];
}
echo '|<br />';
}
}[/PHP]

I understand how a for loop works, but I don't really know what it means by $column, $row etc.

Is it just random variable examples that it's using? Or does it actually mean something in the array?

EDIT: Actually, I figured out the code, and how to use the arrays better. If you could answer my first question on how often arrays are used though, that would be nice! :banana:
__________________
http://bcssa.andrewsmythe.net

Last edited by MrMan9879; Jan 11th, 2006 at 8:52 PM.
MrMan9879 is offline   Reply With Quote