[thelist] PHP: display leading zero
Raul Beltran
espiritudelvino@hotmail.com
Thu Oct 5 01:55:52 2000
----- Original Message -----
From: "Lauri Väin" <optima@hot.ee>
> The question: How can I make PHP display the leading zero in case the
number is
> only one digit?
$d = $timearray['mday'];
// Day
echo "<select name='listDays'>";
for($i=1;$i<=31;$i++){
echo "<option";
if($i == $d){
echo " selected ";
}
echo ">" . sprintf("%02d",$i) . "</option>";
}
echo "</select>";
The line with the sprintf will do what you want... I did this for a project
and worke fine.