my question suppose to be pretty basic.
ie. I got the value of $price from mysql db.
Code: Select all
$price = number_format($price,2);Moderator: General Moderators
Code: Select all
$price = number_format($price,2);Code: Select all
<?php
$price1 = 12.48;
$price2 = 12.02;
$price3 = 12.56;
$price4 = 12.76;
$num1 = round($price1/0.5) * 0.5;
$num2 = round($price2/0.5) * 0.5;
$num3 = round($price3/0.5) * 0.5;
$num4 = round($price4/0.5) * 0.5;
echo number_format($num1, 2);
echo '<br />';
echo number_format($num2, 2);
echo '<br />';
echo number_format($num3, 2);
echo '<br />';
echo number_format($num4, 2);
?>