加上具有重复列名的数组成员

时间:2019-12-01 08:34:29

标签: php arrays laravel

我想通过laravel创建一个商店站点,现在我创建购物车页面。

我将用户要购物的所有产品保存在阵列中。

像这样:


                $array = [
                    [
                      'product' => 'ICDL',
                      'price' => 30,
                      'quantity' => 1
                    ],
                    [
                      'product' => 'ICDL',
                      'price' => 30,
                      'quantity' => 1
                    ],
                    [
                      'product' => 'ICDL',
                      'price' => 30,
                      'quantity' => 1
                    ],
                    [
                      'product' => '3DMAX',
                      'price' => 1030,
                      'quantity' => 1
                    ],
                    [
                      'product' => 'autocat',
                      'price' => 33,
                      'quantity' => 1
                    ],
                    [
                      'product' => 'autocat',
                      'price' => 33,
                      'quantity' => 1
                    ]
                  ];

我想这样在购物车页面中显示


<h2>ICDL</h2>
<h3>quantity</h3>
<p>3</p>
<h3>price</h3>
<p>90</p>

<hr>
<hr>



<h2>3DMAX</h2>
<h3>quantity</h3>
<p>1</p>
<h3>price</h3>
<p>1030</p>

<hr>
<hr>


<h2>autocat</h2>
<h3>quantity</h3>
<p>2</p>
<h3>price</h3>
<p>66</p>


您应该知道我正在使用laravel。如果您可以为laravel编写代码,但如果您不能为laravel编写代码,则只需为php编写代码即可。我想我可以将其转换为laravel。

0 个答案:

没有答案