我有這個。它是用 laravel 制作的
public function render()
{
$percentageNotAnswered = ($noanswer * 100) / $mytickets;
還有這個:
<span class="text-2xl font-semibold text-gray-700"> {{ $noanswer ?? "" }} </span>
<span class="text-sm text-gray-500"> {{ $percentageNotAnswered ?? '' }}% </span>
<div class="text-gray-500">Tickets with no Answer</div>
</div>
它顯示的結果類似于 33.333333333333% 我怎樣才能四舍五入到小數點后兩位?謝謝
uj5u.com熱心網友回復:
簡單的php函式:
round(($noanswer * 100) / $mytickets, 2);
https://www.php.net/manual/en/function.round.php
uj5u.com熱心網友回復:
它的 PHP round()函式。
所以你想使用:
$percentageNotAnswered = round(($noanswer * 100) / $mytickets), 2);
基本上是round($number,$decimal_places)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/436656.html
