access elements in array
Posted: Sun Mar 01, 2009 12:48 am
Im new to php and im working on an array.
Here is my code
Now the above code i wrote is able to give me the values of each element. But how do i get the element names itself (e.g. ProductA, ProductB etc) these elements will be dynamic, so i cant hard code it. Or should i be using classes??
Any help is appreciated.
Here is my code
Code: Select all
$shop = array
(
array
(
"ProductB"=>32,
"ProductC"=>19,
"ProductD"=>55
),
array
(
"OpeningStock"=>55,
"DirectCosts"=>33,
"EndSTock"=>33
),
for ($row = 0; $row < 2; $row++) //number of rows Stay the same
{
echo "The row number " . $row . "</br>";
foreach($shop[$row] as $key => $value)
{
echo $value . "</br>";
}
}
Any help is appreciated.