我想用PHP计算一个数字的百分比。例如:
$percentage = 50;
$totalWidth = 350;
在本例中,350 的 50% = 175
我该怎么做?
$percentage = 50;
$totalWidth = 350;
$new_width = ($percentage / 100) * $totalWidth;
将
$percentage
除以 100 并乘以 $totalWidth
.简单的数学。