在我的刀片中,我编写了以下代码
{{($sub /$Tot)*100 }}%
我的输出是
42.857142857143%
我需要获得这种格式的输出
42%
我试过下面的代码,但我得到了相同的值
{{round(($sub /$Tot)*100) }}%
你的回合应该是为了整体输出,试试这个
$output = (25/47)*100;
echo round($output);
round
将给出最接近的值。CCD_ 2将在0的方向上给出最接近的值。下面的数字应该是42而不是43。
{{(int)(($sub /$Tot)*100) }}%
使用十进制数的int
值,
$value = (int)$decimal;
即在视图中,
{{(int)(($sub /$Tot)*100) }}%
您正在寻找PHP的floor((函数。
{{ floor(($sub /$Tot)*100) }}%