I populate the $_SESSION['products'] array from a file:
$myFile = '.\products.txt';
$handle = fopen($myFile, 'r');
while (!feof($handle))
{
$prod = explode('|', fgets($handle));
$_SESSION['products'] = array($prod[4] => array(
'name' => $prod[0],
'price' => $prod[1],
'description' => $prod[2],
'image' => $prod[3]));
}
Then I want to loop through it, printing all the names and prices:
foreach ($_SESSION['products'] as $prodID=>$value) {
echo $_SESSION['products'][$value]['name'];
echo $_SESSION['products'][$value]['price'];
}
But it doesn't seem to work!
print_r($_SESSION['products'])??Array ( [ylbulb] => Array ( [name] => 60W Yellow Bulb [price] => 7.95 [description] => Yellow Bulb description... [image] => ylbulb.png ) )So all items are not being loaded into the array!