Question:
In php, how do I format my numbers so that all numbers have a double digit. I am displaying
the number of days in a month and have to match the date formatted for day.
Answer:
Just check the number value during a loop in php to see if it's less then 10.
Php code is below:
If so then add the leading zero to your string.
<?
for ($num = 1; $num <= 31; $num++) {
if($num<10)
$day = "0$num"; // add the zero
else
$day = "$num"; // don't add the zero
echo "<p>$day</p>";
?>
NewSourceMedia is providing links to these listings as
a courtesy, and makes no representations regarding the content or
any information related thereto. Any questions, complaints or claims
regarding the downloaded content or details must be directed to the appropriate
publisher. We do not encourage or condone the use of any
software in violation of applicable laws.