我有产品价格的历史列表(按created_at排序),如下所示:
Array
(
[0] => stdClass Object
(
[id] => 1
[product_id] => 49
[price] => 14520000.0000
[created_at] => 1592501154
)
[1] => stdClass Object
(
[id] => 2
[product_id] => 49
[price] => 14000000.0000
[created_at] => 1592587554
)
[2] => stdClass Object
(
[id] => 4
[product_id] => 49
[price] => 14800000.0000
[created_at] => 1592673954
)
[3] => stdClass Object
(
[id] => 5
[product_id] => 49
[price] => 10000000.0000
[created_at] => 1592760354
)
[4] => stdClass Object
(
[id] => 6
[product_id] => 49
[price] => 14000000.0000
[created_at] => 1592846754
)
[5] => stdClass Object
(
[id] => 7
[product_id] => 49
[price] => 14000000.0000
[created_at] => 1592933154
)
[6] => stdClass Object
(
[id] => 8
[product_id] => 49
[price] => 14000000.0000
[created_at] => 1593019554
)
)
现在,为了在表中显示数据,我使用foreach如下方法列出了价格:
<?php foreach($product_prices_list as $product_price_list):?>
<tr>
<td><?= esc($product_price_list->created_at);?></td>
<td class="text-center"><?= esc(number_format($product_price_list->price));?></td>
<td class="text-center"></td> //show difference between of two price
</tr>
<?php endforeach;?>
我可以在表中看到真实的输出,但我需要在第三列中显示两个价格之间的差异,如下图所示:
我如何显示列表中两个价格之间的差异?!
ITMISS
慕田峪4524236