I have this. Its made in laravel
public function render()
{
$percentageNotAnswered = ($noanswer * 100) / $mytickets;
And also this:
<span > {{ $noanswer ?? "" }} </span>
<span > {{ $percentageNotAnswered ?? '' }}% </span>
<div >Tickets with no Answer</div>
</div>
And it show the result like 33.333333333333% How can I round to just 2 decimals? Thanks
CodePudding user response:
Simple php function:
round(($noanswer * 100) / $mytickets, 2);
https://www.php.net/manual/en/function.round.php
CodePudding user response:
Its PHP round() function.
So you wanna use:
$percentageNotAnswered = round(($noanswer * 100) / $mytickets), 2);
It is basically round($number,$decimal_places)