Hey guys,
I'm trying to update an existing site and I'm having a few issues with an array in terms of sorting the results of an array into a simple div layout. It currently works and the output is working fine. However I want to define a category as a parent.
<?php
$_SESSION['cart'] = array(0 => array(0 => "empty"));
$increment = count($_SESSION['cart']);
$_SESSION['cart'][$increment] = array("category" => $category,
"product" => $product);
$increment = count($_SESSION['cart']) - 1;
for ($i = 1; $i <= $increment; $i++)
{
echo "<div style=\"clear: both;\">" . $_SESSION['cart'][$i]['category'] . "</div>";
echo "<div style=\"clear: both;\">" . $_SESSION['cart'][$i]['product'] . "</div>";
}
?>
This works, however I'm getting a repeat Category title for each loop. Where I would prefer the category to be a parent for many products that relate to the category.
Displayed like this perhaps?
Category
Product
Product
Category
Product
Product
Category
Product
Product
Any help would be great ... Thanks in advance.