project3 Posted February 9, 2008 Share Posted February 9, 2008 I have a number that I want to make sure the leading zero doesn't get striped before adding to my db. 020808 it will always be six digits. thanks in advance. Link to comment https://forums.phpfreaks.com/topic/90154-number-format/ Share on other sites More sharing options...
kts Posted February 9, 2008 Share Posted February 9, 2008 Put it in a string? Link to comment https://forums.phpfreaks.com/topic/90154-number-format/#findComment-462296 Share on other sites More sharing options...
project3 Posted February 10, 2008 Author Share Posted February 10, 2008 That doesn't work for some reason. Link to comment https://forums.phpfreaks.com/topic/90154-number-format/#findComment-463411 Share on other sites More sharing options...
sasa Posted February 10, 2008 Share Posted February 10, 2008 try <?php $number = 2808; $string = sprintf('%06d',$number); echo $string; ?> Link to comment https://forums.phpfreaks.com/topic/90154-number-format/#findComment-463429 Share on other sites More sharing options...
project3 Posted February 10, 2008 Author Share Posted February 10, 2008 try <?php $number = 2808; $string = sprintf('%06d',$number); echo $string; ?> Thanks thats perfect. Link to comment https://forums.phpfreaks.com/topic/90154-number-format/#findComment-463436 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.