Reputation: 305
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.
Upvotes: 0
Views: 253
Reputation: 29462
$_SESSION['test']
is not an array - it is an object of Test
class with property maincurrency
which access is limited to private
- it means you can not directly access this property.
To get it's value you have either:
public
in class definitionUpvotes: 3