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. 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); 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 Link to comment https://forums.phpfreaks.com/topic/237038-formatting-numbers/#findComment-1218396 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.