bmbuk Posted June 29, 2007 Share Posted June 29, 2007 Hi guys, I've tried to do this conversion but no luck until now. Is it actually possible convert from 0000000133400 to 13.3400 using printf ? I would be very grateful if anyone out there could give me a hand with this one. Thanks a lot B. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted June 29, 2007 Share Posted June 29, 2007 number_format($num, 4, '.' ,''); Quote Link to comment Share on other sites More sharing options...
bmbuk Posted June 29, 2007 Author Share Posted June 29, 2007 <?php $num = "0000000006241" echo number_format($num, 4, '.' ,''); ?> Output: --------- 6241.0000 Quote Link to comment Share on other sites More sharing options...
HaLo2FrEeEk Posted June 29, 2007 Share Posted June 29, 2007 Well what do you want? Do you want it to always have 4 decimal places? round($num, 4); Should work. Quote Link to comment Share on other sites More sharing options...
bmbuk Posted June 29, 2007 Author Share Posted June 29, 2007 Hi HaLo2FrEeEk, I want from this number 0000000133400 get to this => 13.3400. That is, strip the zeros off and set the decimal symbol in the right place (3 decimal places) I have gone through loads of functions on the manual but haven't yet found one that actually "add" (instead of move) the decimal symbol on a decimal. I wouldn't like to use substring, unless there is no other way to do this. Thanks a lot Bruno Quote Link to comment 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.