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. Quote 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() Quote 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); Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.