deanlee17
asked on
Round calculation to the nearest pound
Hi guys,
I have the following calc, how can I round it to the nearest pound? £2.50 would be £3.00 and £2.49 would be £2.00 etc...
<?php $TheVar = $rows_product[$i]['product _rrp'] - $rows_product[$i]['product _price']; ?>
Thanks,
Dean
I have the following calc, how can I round it to the nearest pound? £2.50 would be £3.00 and £2.49 would be £2.00 etc...
<?php $TheVar = $rows_product[$i]['product
Thanks,
Dean
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hi.. please use this
float round ( float $val [, int $precision = 0 [, int $mode = PHP_ROUND_HALF_UP ]] )
or
<?php
echo(round(0.60) . "<br>");
echo(round(0.50) . "<br>");
echo(round(0.49) . "<br>");
echo(round(-4.40) . "<br>");
echo(round(-4.60));
?>
float round ( float $val [, int $precision = 0 [, int $mode = PHP_ROUND_HALF_UP ]] )
or
<?php
echo(round(0.60) . "<br>");
echo(round(0.50) . "<br>");
echo(round(0.49) . "<br>");
echo(round(-4.40) . "<br>");
echo(round(-4.60));
?>
Some good learning resources to help you get started with PHP...
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html
... And some things to avoid as you get started with PHP...
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12293-AntiPHPatterns-and-AntiPHPractices.html
Best of luck with your project, ~Ray
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_11769-And-by-the-way-I-am-new-to-PHP.html
... And some things to avoid as you get started with PHP...
https://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/A_12293-AntiPHPatterns-and-AntiPHPractices.html
Best of luck with your project, ~Ray
Open in new window