Jeric Javier Jeric Javier - 28 days ago 8
PHP Question

rounding off decimal in php

$discount = $total * $disc;


I have this php code but sometimes it results into a decimal how can I round it off. One case is $discount = 157 * .20. I want to round it off so there will be no decimal.

Answer Source

$discount = floor($total * $disc); or $discount = ceil($total * $disc);