horsetags Posted October 18, 2007 Share Posted October 18, 2007 Hi, I have a simple include with a price list - $AZ2L=41.0; and i echo this on the page <?php echo($AZ2L); ?> But the result is - 41 and i would like 41.00 Being a bit of a beginner, i expect this is simple, but I am not sure how to do this. If anyone can help that would be great. Thanks in advance Paul Quote Link to comment https://forums.phpfreaks.com/topic/73829-solved-displaying-zeros-in-echo/ Share on other sites More sharing options...
clanstyles Posted October 18, 2007 Share Posted October 18, 2007 Try something along the lines of number_format. http://us.php.net/number_format Quote Link to comment https://forums.phpfreaks.com/topic/73829-solved-displaying-zeros-in-echo/#findComment-372481 Share on other sites More sharing options...
atlanta Posted October 18, 2007 Share Posted October 18, 2007 When you assign the variable a value use quotes . <?php $AZ2L = "41.00"; echo($AZ2L); ?> that will output the result you want. Quote Link to comment https://forums.phpfreaks.com/topic/73829-solved-displaying-zeros-in-echo/#findComment-372482 Share on other sites More sharing options...
esukf Posted October 18, 2007 Share Posted October 18, 2007 <?php echo number_format($AZ2L, 2, '.', ''); ?> http://uk3.php.net/manual/en/function.number-format.php Quote Link to comment https://forums.phpfreaks.com/topic/73829-solved-displaying-zeros-in-echo/#findComment-372483 Share on other sites More sharing options...
clanstyles Posted October 18, 2007 Share Posted October 18, 2007 esukf you ninja..I wanted to do this lOL. But yes, nice Quote Link to comment https://forums.phpfreaks.com/topic/73829-solved-displaying-zeros-in-echo/#findComment-372485 Share on other sites More sharing options...
horsetags Posted October 18, 2007 Author Share Posted October 18, 2007 Thanks all, I used the quotes answer as it was easier to implement :-) Paul Quote Link to comment https://forums.phpfreaks.com/topic/73829-solved-displaying-zeros-in-echo/#findComment-372678 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.