How do I get a part of a $_session array?
<?php
session_start();
foreach($_SESSION['cart'] as $product_id => $quantity) {
echo $product_id . "=>" . $quantity . "<br>";
}
?>
This outputs
1 => 6
4 => 5
2 => 5
But what I ultimately want is the value of only one of them. Lets say I only want the second( 4 => 5 ).
So I tried this :echo $_SESSION['cart'][1]; And ofcourse it showed me nothing.
So my question is how to get it. Sorry if this is a stupid/unclear question.