Limiting Decimal Places in Floating Point Numbers in PHP


Limit the number of decimal places in a float using number_format().

Source Code

$float = 3.14159;
echo number_format($float, 2); // Outputs: 3.14
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments