Thursday, 5 September 2013

PHP - Multidimensional array not getting stored properly

PHP - Multidimensional array not getting stored properly

I'm trying to create a simple 2D array in PHP and it doesn't seem to work
as described. For instance, I tried the sample code from the w3schools.com
site:
$cars = array
(
array("Volvo",100,96),
array("BMW",60,59),
array("Toyota",110,100)
);
But when I call:
echo "$cars[1][1]";
it outputs "Array[1]", not "60". As far as I can tell, the only thing
that's getting stored is the string "Array". It doesn't matter how big or
small the array is or what method I declare it in or whether it's string
or integer, etc... it doesn't actually store the proper data in any sort
of array format.

No comments:

Post a Comment