1
我有一個多值的數組。用PHP計算總數的多個值的百分比
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%等。
我該怎麼做?
你需要知道的所有值的總和,然後就'( $計數/ $總和)* 100' – dage5