pedrobcabral Posted September 27, 2006 Share Posted September 27, 2006 Sorry guys but the following code:[code]<?php$numero1 = "01";$numero2 = "01";$conta = $numero1 + $numero2;echo $conta;?>[/code]The variable $conta outputs the number "2". How can I make it to be "02" instead of "2"?Thank you. (I put the double quote to try to turn this a string, not a number as it is now, but I did not sucededd) Quote Link to comment Share on other sites More sharing options...
Barand Posted September 27, 2006 Share Posted September 27, 2006 You need to format the output with printf()[code]<?php$numero1 = "01";$numero2 = "01";$conta = $numero1 + $numero2;printf ('%02d', $conta);?>[/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.