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? Link to comment https://forums.phpfreaks.com/topic/51515-solved-calculations/ 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; ?> Link to comment https://forums.phpfreaks.com/topic/51515-solved-calculations/#findComment-253714 Share on other sites More sharing options...
chigley Posted May 15, 2007 Share Posted May 15, 2007 <?php echo sprintf("%02d", (4-1)); ?> Link to comment https://forums.phpfreaks.com/topic/51515-solved-calculations/#findComment-253724 Share on other sites More sharing options...
taith Posted May 15, 2007 Share Posted May 15, 2007 strpad(); Link to comment https://forums.phpfreaks.com/topic/51515-solved-calculations/#findComment-253729 Share on other sites More sharing options...
Ninjakreborn Posted May 15, 2007 Author Share Posted May 15, 2007 thanks. Link to comment https://forums.phpfreaks.com/topic/51515-solved-calculations/#findComment-253749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.