tqla Posted October 23, 2009 Share Posted October 23, 2009 Hello. My code reads like this: echo "Your discount is: $" . $discount; Which in this case ends up reading like this "Your discount is: $19.8" As you can see, the value of $discount will omit the hundredths place if it is a zero. If it is not a zero it shows the actual number. Is there any way to add a zero to the hundredths place if this is the case? Thank you. Link to comment https://forums.phpfreaks.com/topic/178685-solved-add-zero-to-the-hundredths-place-if-needed/ Share on other sites More sharing options...
mikesta707 Posted October 23, 2009 Share Posted October 23, 2009 look into number_format() Link to comment https://forums.phpfreaks.com/topic/178685-solved-add-zero-to-the-hundredths-place-if-needed/#findComment-942539 Share on other sites More sharing options...
tqla Posted October 23, 2009 Author Share Posted October 23, 2009 Thanks mikesta707. That worked! I did this: number_format($discount,2); Link to comment https://forums.phpfreaks.com/topic/178685-solved-add-zero-to-the-hundredths-place-if-needed/#findComment-942548 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.