Simple probably but can’t get it right. I need a value out of an session array here’s how its build:
print_r($_SESSION); //gives:
Array
(
[cart] => cart Object
(
[config] => Array()
[maincurrency:cart:private] => GBP
)
)
The code so far:
foreach($_SESSION['cart'] as $category => $thing) {
echo $category; //echo's config |the value I need GBP
echo $thing; // echo's Array
if ($category == 'maincurrency:cart:private')
{
echo 'found_it'; //doesn't echo
echo $category; //echo's nothing |the value I need GBP
echo $thing; // echo's nothing
}
}
The string I need is ‘GBP’ from maincurrency:Test:private.
$_SESSION['test']is not an array – it is an object ofTestclass with propertymaincurrencywhich access is limited toprivate– it means you can not directly access this property.To get it’s value you have either:
publicin class definition