Take your result and use sprintf.
$variable_fixed=sprintf("%06s",$variable);
The above code with make $variable 6 digits long and fill all "empty" spaces
with zeros. So if $variable=42, the $variable_fixed with be 000042.
Specifically, for your code below, I would say put an if statement after the
while, but before the echo.
if ($i==0){
$i = sprintf("%02s",$i);
}
?>
<option value="<echo "$i"' ?>">"<? echo "$i" ?></option>
<?
John
"Shaun" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> How can i add a leading zero to the first result of this loop so that i
get
> 00, 15, 30, 45?
>
> <select name="start_date_minute">
> <?php
> $i = 0;
> while ($i <= 45){
> echo '<option value="'.$i.'">'.$i.'</option>';
> $i+=15;
> }
> ?>
>
> Thanks for your help
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php