"product1、$ 1,35; product2、$ 1,50; product3のようなテーブルの中に、 $ 5,50"配列の複数の文字列を隣り合わせに設定する方法
しかし、私はそれらを印刷するとき、今、彼らは私の画面上で、このように取得:ここ
は私のJSONデコードされた配列のvar_dump
です:
array(4) { ["product_id"]=> int(1) ["product_name"]=> string(12) "Broodje Kaas" ["product_quantity"]=> int(1) ["product_price"]=> int(205) } array(4) { ["product_id"]=> int(2) ["product_name"]=> string(11) "Broodje ham" ["product_quantity"]=> int(3) ["product_price"]=> int(107) } array(4) { ["product_id"]=> int(1) ["product_name"]=> string(10) "Broodje ei" ["product_quanity"]=> int(1) ["product_price"]=> int(205) } array(4) { ["product_id"]=> int(2) ["product_name"]=> string(11) "Broodje kip" ["product_quanity"]=> int(3) ["product_price"]=> int(107) } array(4) { ["product_id"]=> int(1) ["product_name"]=> string(12) "Broodje Kaas" ["product_quanity"]=> int(1) ["product_price"]=> int(205) } array(4) { ["product_id"]=> int(2) ["product_name"]=> string(11) "Broodje ham" ["product_quanity"]=> int(3) ["product_price"]=> int(107) }
と私の$ productidsのvar_dump
:ここ
array ([0] => Array ([id] => 1 [order_items] => [{"product_id":1,"product_name":"Broodje Kaas","product_quantity":1,"product_price":205},{"product_id":2,"product_name":"Broodje ham","product_quantity":3,"product_price":107}] [order_price] => 2,50 [order_date] => 2017-10-12 18:08:43 [order_state] => 1 [order_is_paid] => 1) [1] => Array ([id] => 2 [order_items] => [{"product_id":1,"product_name":"Broodje ei","product_quanity":1,"product_price":205},{"product_id":2,"product_name":"Broodje kip","product_quanity":3,"product_price":107}] [order_price] => 3,00 [order_date] => 2017-10-12 18:04:38 [order_state] => 0 [order_is_paid] => 0) [2] => Array ([id] => 3 [order_items] => [{"product_id":1,"product_name":"Broodje Kaas","product_quanity":1,"product_price":205},{"product_id":2,"product_name":"Broodje ham","product_quanity":3,"product_price":107}] [order_price] => 5,60 [order_date] => 2017-10-12 14:40:51 [order_state] => 2 [order_is_paid] => 1)) Array ([0] => Array ([id] => 1 [order_items] => [{"product_id":1,"product_name":"Broodje Kaas","product_quantity":1,"product_price":205},{"product_id":2,"product_name":"Broodje ham","product_quantity":3,"product_price":107}] [order_price] => 2,50 [order_date] => 2017-10-12 18:08:43 [order_state] => 1 [order_is_paid] => 1) [1] => Array ([id] => 2 [order_items] => [{"product_id":1,"product_name":"Broodje ei","product_quanity":1,"product_price":205},{"product_id":2,"product_name":"Broodje kip","product_quanity":3,"product_price":107}] [order_price] => 3,00 [order_date] => 2017-10-12 18:04:38 [order_state] => 0 [order_is_paid] => 0) [2] => Array ([id] => 3 [order_items] => [{"product_id":1,"product_name":"Broodje Kaas","product_quanity":1,"product_price":205},{"product_id":2,"product_name":"Broodje ham","product_quanity":3,"product_price":107}] [order_price] => 5,60 [order_date] => 2017-10-12 14:40:51 [order_state] => 2 [order_is_paid] => 1)) Array ([0] => Array ([id] => 1 [order_items] => [{"product_id":1,"product_name":"Broodje Kaas","product_quantity":1,"product_price":205},{"product_id":2,"product_name":"Broodje ham","product_quantity":3,"product_price":107}] [order_price] => 2,50 [order_date] => 2017-10-12 18:08:43 [order_state] => 1 [order_is_paid] => 1) [1] => Array ([id] => 2 [order_items] => [{"product_id":1,"product_name":"Broodje ei","product_quanity":1,"product_price":205},{"product_id":2,"product_name":"Broodje kip","product_quanity":3,"product_price":107}] [order_price] => 3,00 [order_date] => 2017-10-12 18:04:38 [order_state] => 0 [order_is_paid] => 0) [2] => Array ([id] => 3 [order_items] => [{"product_id":1,"product_name":"Broodje Kaas","product_quanity":1,"product_price":205},{"product_id":2,"product_name":"Broodje ham","product_quanity":3,"product_price":107}] [order_price] => 5,60 [order_date] => 2017-10-12 14:40:51 [order_state] => 2 [order_is_paid] => 1))
とは私のコードである
<table class="table table-striped">
<?php $output = "<tr><th># </th><th>Producten </th><th>Prijs </th></tr>";?>
<tbody>
<tr>
UW bestelde producten
<?php foreach ($productsids as $value) {
$output .= "<tr>";
$orderitems = json_decode($value['order_items'], true);
$output .= "<td>" .$value['id']. "</td>";
foreach ($orderitems as $item) {
var_dump($item);
$output .= "<td>" .$item['product_name']. "</td>";
$output .= "<td>" .$item['product_price']. "</td>";
//$output .= "<td>" .$item['product_quantity']. "</td>";
}
$output .= "</tr>";
}
echo $output;
?>
</tr>
</tbody>
あなたはproductsidsますprint_r($ productsids)$を印刷することができますか? –
@RavinderReddyこれが表示されます:https://gyazo.com/74dcf79df527d5730f43df55be2bf99b –
イメージは動作しません。コードを貼り付けます。 –