I have the following script that outputs a shipping amount number depending on what the user sets it to. The user should always set the number as “0.00” or “5.00” or “10.00” but I have some users who can’t read, so they set it as “5” or as “10” without the decimals. In the output, I have it like:
$output_box = $total['shipping'];
How do I change it so that it auto-detects if there’s no decimals, and automatically adds “.00” to it?
For example, if the amount is “4” then it should change it to “4.00” but when the amount is “4.10” or “5.00” it should do nothing.
Any help is greatly appreciated 🙂
Use
number_format():