Have to round the number in php. I have tried like below,
round(12.4569,2);
it will return 12.46. its OK.
But, round(12.4003,2);
the output is 12.4
But need the output 12.40
suggestion please...
Use number_format :
number_format((float)$number, 2, '.', '');
The solution using sprintf
function:
print_r(sprintf("%.2f",12.4003,2)); // 12.40
print_r(sprintf("%.2f",12.4569,2)); // 12.46
Try using this in ur code :
number_format(12.4003,2);