I'm working on a uni assignment and ive been looking at some code for hours now and I'm lost :(
I need to take a session array storing cart items and then display the full item from another array
Data Array
$pumps = array(
'GB96CSUN' => array(
'img' => 'images/GB96CSUN.gif',
'title' => '1938 Gilbert & Barker Model 96C Sunray',
'desc' => 'Beautiful authentic yellow and orange paint scheme highlight this Sunray Gilbert & Barker early electric gas pump. Completely restored inside and out. Correct Gilbarco nozzle. Museum quality. (Rolling Stand Not Included)',
'price' => '$5495 ',
),
'TK39TLSIG' => array(
'img' => 'images/TK39TLSIG.gif',
'title' => '1939 Tokheim Model 39 (Tall) Signal Gasoline',
'desc' => 'Impressive size and paint scheme, this Tokheim 39 Tall Signal Gasoline pump signaled that the end of the pre-war, "tall" pump era was coming to a close. This magnificent example with its vintage gas brand is near mint. Completely restored. Correct Tokheim nozzle. Near mint. (Rolling Stand Not Included)',
'price' => '$6495',
),
Session Array
$_SESSION['cart'][0];
Array ( [0] => GP8002 [1] => GP792 [2] => RGP300A )
Display Code
foreach ($_SESSION['cart'] as $cartlist){
if (in_array($cartlist, $pumps)){
echo "<div class='container'>";
echo "<nav>";
echo"<a href='#'><img src='images/$pid.jpg' height='250px'></a>";
echo"</nav>";
echo "<article>";
echo "<h1>{$cartlist['title']}</h1>";
echo "<p>{$cartlist['desc']}</p>";
echo "<p> Price :{$cartlist['price']</p>";
echo "</article>";
echo "</div>";
}
}
Cart Output
Array
(
[0] => GP8002
[1] => GP792
[2] => RGP300A
)