etrader Posted May 21, 2011 Share Posted May 21, 2011 How I can format the number in a string to be displayed as four-digit. I mean transforming 1 to 0001; and 54 to 0054. Quote Link to comment https://forums.phpfreaks.com/topic/237038-formatting-numbers/ Share on other sites More sharing options...
wildteen88 Posted May 21, 2011 Share Posted May 21, 2011 Using sprintf $num = 4; echo sprintf("%04d", $num); Quote Link to comment https://forums.phpfreaks.com/topic/237038-formatting-numbers/#findComment-1218376 Share on other sites More sharing options...
etrader Posted May 21, 2011 Author Share Posted May 21, 2011 Thanks, exactly what I needed Quote Link to comment https://forums.phpfreaks.com/topic/237038-formatting-numbers/#findComment-1218396 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.