Auto Posted January 21, 2007 Share Posted January 21, 2007 Hi there,I'm curious if there is a way to strip leading zeroes from a number? I am making a page to calculate scores from a game, and, when it shows the scores on the "leaderboard" page, it will show numbers below 100 as 05, 020, etc., etc., when it should show 5 or 20.Any way to do this without having to run a giant if, then statement?Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/35047-stripping-leading-zeroes-in-numbers/ Share on other sites More sharing options...
kobmat Posted January 21, 2007 Share Posted January 21, 2007 Try echo (int)$score; Link to comment https://forums.phpfreaks.com/topic/35047-stripping-leading-zeroes-in-numbers/#findComment-165328 Share on other sites More sharing options...
Jessica Posted January 21, 2007 Share Posted January 21, 2007 intval() should also work. Link to comment https://forums.phpfreaks.com/topic/35047-stripping-leading-zeroes-in-numbers/#findComment-165329 Share on other sites More sharing options...
Auto Posted January 21, 2007 Author Share Posted January 21, 2007 Thank you both for the speedy responses. The latter worked like a charm! Thanks! Link to comment https://forums.phpfreaks.com/topic/35047-stripping-leading-zeroes-in-numbers/#findComment-165345 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.