Ninjakreborn Posted May 15, 2007 Share Posted May 15, 2007 <?php echo 04 - 1; ?> that echo's 3 I need it to echo 03, is there an easy way to do this? Quote Link to comment Share on other sites More sharing options...
clown[NOR] Posted May 15, 2007 Share Posted May 15, 2007 maybe if you add an if statement? <?php $calc = 04 - 1; if (strlen($calc) == 1) { $calc = "0$calc"; } echo $calc; ?> Quote Link to comment Share on other sites More sharing options...
chigley Posted May 15, 2007 Share Posted May 15, 2007 <?php echo sprintf("%02d", (4-1)); ?> Quote Link to comment Share on other sites More sharing options...
taith Posted May 15, 2007 Share Posted May 15, 2007 strpad(); Quote Link to comment Share on other sites More sharing options...
Ninjakreborn Posted May 15, 2007 Author Share Posted May 15, 2007 thanks. 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.