So I am trying to figure out Multidimensional Arrays in PHP. So I want to make a simple array that houses the sum of it position in the array,:queasy: Something like $array[5][6] contains the value 11. So I doctored up the following function to do that.
$nums;
function buildArrayOne()
{
for($tick = 0; $tick < 20; $tick++)
{
for($tock = 0; $tock < 30; $tock++)
{
$num[$tick][$tock] = $tick + $tock;
}//end tock for
}//end tick for
}//end buildArrayOne
And then I want to output the results to a table using this function:
function displayArrayNestedFors($arr)
{
for($row = 0; $row < 10; $row++)
{
print "<tr>";
for($col = 0; $col < 20; $col++)
{
$disp = $nums[$row][$col];
print "<td>$disp</td>";
}//end col for
print "</tr>";
}//end row for
}//end displayArrayNestedFors
But whenever I run the script it displays nothing. Can someone tell me why, and how to fix it?
I am currently using a book called "Teach Yourself PHP in 24 hours" I really like the book it just lacks some description and explanation that I would like to have. All of the multidimensional arrays in that book are associative arrays. While a nice feature they are a pain in the ass to build up.
Anyway thanks for any help.