Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想用 PHP 计算一个数字的百分比。例如:
$percentage = 50; $totalWidth = 350;
对于此示例,350 的 50% = 175
我怎样才能做到这一点?
$percentage = 50; $totalWidth = 350; $new_width = ($percentage / 100) * $totalWidth;
除以$percentage100 并乘以$totalWidth。简单的数学。
$percentage
$totalWidth