0
我試圖引用此嵌套數組中的「建議」變量,因爲它會吐出for循環。 $ _SESSION [「產品」] - >建議,沒有工作。還有其他類似的問題,但答案很難遵循。 for循環如下。引用嵌套數組中的變量
array(1) {
["products"]=>
array(1) {
[0]=>
array(9) {
["name"]=>
string(20) "m10x1-5-001 IVB bolt"
["code"]=>
string(11) "m10x1-5-001"
["qty"]=>
string(1) "1"
["weight"]=>
string(3) ".03"
["price"]=>
string(5) "37.00"
["image"]=>
string(80) "/images/ProductPhotosLR/m101-5-001/m10x1-5-001-S.jpg"
["description"]=>
string(39) "This is a short description of my item."
["suggested"]=>
string(18) "IVB-METRIC-INSTALL"
["suggestedtext"]=>
string(80) "First time owners of ....."
}
}
}
環路我試圖使用方法:(每個項目在購物車會議將有可能附着建議項目)的循環工作正常,如果語句被分解。
if(!empty($_SESSION["products"]->suggested)) {
echo '<div id="products-wrapper"><h1>Suggested Items</h1><div class="view-cart">';
echo '<table width="750" cellpadding="0" cellspacing="0" style="text-align:center;padding:5px;">';
foreach ($_SESSION["products"] as $cart_itm)
{
echo '<tr><td>'.$cart_itm['suggested'].' '.$cart_itm['suggestedtext'].'</td></tr>';
}
echo '</table></div></div>';
}