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.
我有一个名为 Value 的int,带有一个随机数。根据值,我需要在标签中显示百分比 (0–100%)。
例如,如果值为 30 of 60,则百分比应为 50%。我应该使用什么公式?
(random_value / max_value) * 100
像这样的东西?
if($value > 30 && $value < 60) { $percentage = '50%'; } else { $percentage = ($value / $max_value) * 100 . '%'; }