Array ([0] => Array ([0] => Array ([name] => Heart Choclates [code] => LFB-P-10 [qty] => 1 [type] => main [price] => 1200 [stock] => 5 [image] => choclates-valentines-day.jpg [quantity] => 12 [expdate] => May 27th 2017 [exptime] => 11:00 PM to 12:00 AM [expdtype] => Mid night delivery) [1] => Array ([name] => Birthday Pink [code] => KB-P-5 [qty] => 1 [type] => addon [price] => 600 [stock] => 7 [image] => pink-roses.jpg [expdate] => May 27th 2017 [exptime] => 11:00 PM to 12:00 AM [expdtype] => Mid night delivery)) [1] => Array ([0] => Array ([name] => Red & Yellow Roses [code] => KB-P-6 [qty] => 1 [type] => main [price] => 800 [stock] => 9 [image] => birthday-red-roses.jpg [expdate] => May 27th 2017 [exptime] => 11:00 PM to 12:00 AM [expdtype] => Mid night delivery) [1] => Array ([name] => Signature Cake [code] => KB-P-7 [qty] => 1 [type] => addon [price] => 0 [stock] => 9 [image] => signature-cake.jpg [expdate] => May 27th 2017 [exptime] => 11:00 PM to 12:00 AM [expdtype] => Mid night delivery) [2] => Array ([name] => Truffle Cake [code] => KB-P-8 [qty] => 1 [type] => addon [price] => 10 [stock] => 7 [image] => truffle-cake.jpg [expdate] => May 27th 2017 [exptime] => 11:00 PM to 12:00 AM [expdtype] => Mid night delivery)))
我有一個像這樣的數組..每個訂單數組中的訂單數組和數組。現在我需要將這些數組添加到數據庫中,每行中的訂單和產品由<br/>
分隔。這怎麼可能?提前致謝。在PHP中向數據庫添加多維數組
我用它來打印代碼。
<?php
session_start();
error_reporting(0);
print_r($_SESSION["products"]);
foreach($_SESSION["products"] as $row => $temp){
?>
<div>
<?php
foreach($temp as $innerRow => $cart_itm){
?>
<div><?php echo $cart_itm['code']; ?></div>
<?php
}
?>
</div>
<?php
}
?>
期待這個結果
爲什麼你的意思是「'''現在我需要將這些數組添加到數據庫中,每行中的訂單和產品都由a'''」分隔? – mi6crazyheart
對不起,突破是失蹤。剛剛編輯 –
再次你的意思是'''產品由
'''分隔?你能舉出你預期的產出嗎? – mi6crazyheart