I am writing a script that requires a 3 dimension array for storing data. I've read all I can find in 4 manuals, and gone through numerous pages in the forums searching on arrays, but can't seem to find the answer.. It is probably something simple that I'm missing, but I'm missing it..
I wrote a little test script to see what is wrong, and can't even get it to work.. Here is the script.
for ($a=1; $a<3; ++$a) {
for ($b=1; $b<3; ++$b) {
for ($c=1; $c<3; ++$c) {
$test[$a][$b][$c] = $a*$b*$c;
print "a is $a and b is $b and c is $c
SO test[$a][$b][$c] is $test[$a][$b][$c]<br>";
}
}
}
What I expected as a result was somethin like this
a is 1 and b is 1 and c is 1 SO test[1][1][1] is 1
a is 1 and b is 1 and c is 2 SO test[1][1][2] is 2
a is 1 and b is 2 and c is 1 SO test[1][2][1] is 2
a is 1 and b is 2 and c is 2 SO test[1][2][2] is 4
a is 2 and b is 1 and c is 1 SO test[2][1][1] is 2
a is 2 and b is 1 and c is 2 SO test[2][1][2] is 4
a is 2 and b is 2 and c is 1 SO test[2][2][1] is 4
a is 2 and b is 2 and c is 2 SO test[2][2][2] is 8
But instead I get this:
a is 1 and b is 1 and c is 1 SO test[1][1][1] is Array[1][1]
a is 1 and b is 1 and c is 2 SO test[1][1][2] is Array[1][2]
a is 1 and b is 2 and c is 1 SO test[1][2][1] is Array[2][1]
a is 1 and b is 2 and c is 2 SO test[1][2][2] is Array[2][2]
a is 2 and b is 1 and c is 1 SO test[2][1][1] is Array[1][1]
a is 2 and b is 1 and c is 2 SO test[2][1][2] is Array[1][2]
a is 2 and b is 2 and c is 1 SO test[2][2][1] is Array[2][1]
a is 2 and b is 2 and c is 2 SO test[2][2][2] is Array[2][2]
Can anyone tell me why?
Thanks, I really appreciate your help. this is stumping me.
doug