如何仅使用无状态功能组件来使按钮向k
添加新的$result = [];
$months = [];
foreach($array as $items) {
foreach($items as $item) {
$months[$item['SalesMonth']] = $item['SalesMonth'];
$result[$item['name']][$item['SalesMonth']] = ($result[$item['name']][$item['SalesMonth']]??0) + $item['TotalSales'];
}
}
?>
<table>
<tr>
<th>Product</th>
<?php foreach($months as $month):?>
<th><?=$month;?></th>
<?php endforeach;?>
</tr>
<?php foreach($result as $name => $items):?>
<tr>
<td><?=$name;?></td>
<?php foreach($months as $month):?>
<td><?=$items[$month]??0;?></td>
<?php endforeach;?>
</tr>
<?php endforeach;?>
</table>
组件?
<Card>