0
很简单,但不能正确。我在这里需要的值出会话阵列的是如何构建它:PHP:从数组中获得价值
print_r($_SESSION); //gives:
Array
(
[cart] => cart Object
(
[config] => Array()
[maincurrency:cart:private] => GBP
)
)
至今代码:
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
}
}
我需要的字符串为“英镑”从maincurrency:测试:私人。
做$ category echo'maincurrency:Test:private'? – bozdoz
你试过类别 - >英镑吗? – CountMurphy
你应该删除你的if语句的末尾有一个分号(我确定这只是在帖子中,而不是实际的代码)。 –