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) Link to comment https://forums.phpfreaks.com/topic/22313-newbie-calculation/ 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] Link to comment https://forums.phpfreaks.com/topic/22313-newbie-calculation/#findComment-99954 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.