Format price with 2 decimal places in PHP

sprintf("%01.2f", $price );

Example usage:

sprintf("%01.2f", 10 ); // 10.00
sprintf("%01.2f", 10.5 ); // 10.50


If you found this article useful, help me out by leaving a comment below and clicking the Like button.

This entry was posted in PHP. Bookmark the permalink.

Comments are closed.