The number_format
function in PHP seems to round by default. My understanding is that this function is useful for separating every three numbers with a comma. Like 1403423 becomes 1,404,423 when using number_format.
So, if I have a large number that I want rounded to two decimal places, how can I do this and still have the commas properly displayed?
Desired behavior: 12042.529 --> 12,042.53
$a=12042.529;
echo number_format($a,2,'.',',');
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.