how to call array values based on the main id they linked to?
- by veronica george
In page one,
$add_id2=implode(',',$add_id);
//result is 1,4
$item_type2=implode(',',$item_type_2);
//result is 8,16
$final_total2=implode(',',$final);
//result is 150,430
I pass these values via URL to the page two and store them in session.
$_SESSION['cart'][$car]=
array ('car'=>$car,
'loc_1'=>$location,
array (
'addon_id'=>$a_id,
'item_type'=>$item_type2,
'final_total'=>$final_t
)
);
I call them like this,
foreach($_SESSION['cart'] as $cart=>$things)
{
//display main array value like car id and location id
echo $cart;
foreach($things as $thing_1=>$thing_2)
{
foreach($thing_2['addon_id'] as $thi_2=>$thi_4)
{
//to display addons item for the car id
//this is the id for each addon under the above car
//echo $thi_2;
//this is to echo addon id
$thi_4;
}
}
}
The above loop works . the addon items array loops through inside main array which is car.
If there were two addon items chosen then the addon array will loop twice. Now al I need to do is, How to make $item_type2 and $final_total2 display the value according to the addon id?
PS: Same addon items can be chosen multiple times. They are identified uniquely by id(//echo $thi_2;). Thanks.