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語句的末尾有一個分號(我確定這只是在帖子中,而不是實際的代碼)。 –