I placed
Code: Select all
$sellers = array();
foreach( $cartcontent as $item )
{
$seller = $item['seller'];
unset($item['seller']);
if (!array_key_exists($seller, $sellers))
{
$sellers[$seller] = array();
}
$sellers[$seller][] = $item;
}
inside of a function called get_order(); If I wanted to return an array called $order, Would It be possible to return the $seller array which we created above like so:
Code: Select all
$order['seller'] = $sellers;
return $order
Assuming that I am correct I should be able to get to the sellers array by calling
$order["seller"]. Correct?
Would I think be able to get access to this array by doing something along the lines of
echo $order["sellers"][0][0];
I am using smarty templates with our shopping site and assigned the following:
$smarty->assign( "seller", $order['sellers']);
I then attempt to iterate through the loop on the smarty page like so:
Code: Select all
<h3>{$smarty.const.STRING_ORDER_SHIPPING}</h3>
{section loop=$seller name=i }
<p>Item: <b>{$seller[i].name}</b></p>
<p>Cost: <b>{$seller[i].cost}</b></p>
<p>Seller: <b>{$seller[i].seller}</b></p>
<p>Quantity: <b>{$seller[i].quantity}</b></p>
{/section}
The problem is I am getting this to loop twice but It is not showing the values pulled from the $seller array? Does anyone have any idea why they are not showing up?