How to output a number with two decimal places in PHP?
Hello everyone! I'm a beginner in PHP and I've encountered what seems like a simple task, but I can't figure it out. I need to display numbers with two decimal places on the screen. For example, if I have the number 10, it should display 10.00, if 10.5 — then 10.50, and if 10.56789 — then 10.57 (with rounding).\n\nI tried simply outputting variables through echo, but PHP trims the zeros itself. Here's my code:\n\n```php\n$price = 10;\n$tax = 5.5;\n$total = $price + $tax; // 15.5\n\necho "Price: " . $price; // Outputs 10, but need 10.00\necho "Tax: " . $tax; // Outputs 5.5, but need 5.50\necho "Total: " . $total; // Outputs 15.5, but need 15.50\n```\n\nI read about the number_format() function, but it works strangely. I tried `number_format($price, 2)` — it seems to work, but when I pass a number there