【发布时间】:2017-10-29 04:33:52
【问题描述】:
我有一个包含多个值的数组。
foreach($results as $row) {
$count = $row['count'];
$type = $row['type'];
$array[$type][] = $count;
}
当我将数组输出到表中时,它看起来像这样
Type Count
AA 4
AE 59
AF 13
BB 44
BC 16
BD 36
我现在想要第三列有百分比,但我不知道如何实现?
例如AA 为 5%,AE 为 39% 等等。
我该怎么做?
【问题讨论】:
-
你需要知道所有值的总和,然后
($count/$sum)*100
标签: php arrays rounding percentage