briant Posted September 16, 2006 Share Posted September 16, 2006 How can I get rid of the 0's in front of a number? Thank you Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 16, 2006 Share Posted September 16, 2006 number_format($number);intval($number);Pick one :) Quote Link to comment Share on other sites More sharing options...
briant Posted September 16, 2006 Author Share Posted September 16, 2006 Thank you. I just figured out another way too:$num = $num+0; // so it would turn into a numberbut I guess your way is more correct, thanks again.btw, intval don't really work because for some reason:echo intval(042); // 34 Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted September 16, 2006 Share Posted September 16, 2006 [code]<?php$number = '000123';echo number_format($number)."\n";echo intval($number);?>[/code] outputs [code]123123[/code] for me... Quote Link to comment Share on other sites More sharing options...
Barand Posted September 16, 2006 Share Posted September 16, 2006 [code]<?phpecho intval(042); // 34echo '<br>';echo intval('042'); // 42?>042 means treat as an octal number (base 8)'042' string value equal to 42[/code] 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.