PDA

View Full Version : how to print a 3 characters digit ?



OKtrust
December 27th, 2004, 12:22 PM
hi all,
I have this code:


<?
for ($i=001; $i <= 200; $i++) {
echo ("$i <br>");
}
?>


and I want it will print from 001 to 200 (not 1 to 200)
how do I do it guys ? thanks

and here is my gift for you if you solve that problem:


<?
for ($i=001; $i <= 200; $i++) {

echo ("<a href='http://www.dns.tlw.cn/1/JPEG640/013/151_200/SM'.$i.'_L.jpg'> http://www.dns.tlw.cn/1/JPEG640/013/151_200/SM".$i."_L.jpg</a> </br>");
}
?>

λ
December 27th, 2004, 02:32 PM
hi all,
I have this code:


<?
for ($i=001; $i <= 200; $i++) {
echo ("$i <br>");
}
?>


and I want it will print from 001 to 200 (not 1 to 200)
how do I do it guys ? thanks

and here is my gift for you if you solve that problem:


<?
for ($i=001; $i <= 200; $i++) {

echo ("<a href='http://www.dns.tlw.cn/1/JPEG640/013/151_200/SM'.$i.'_L.jpg'> http://www.dns.tlw.cn/1/JPEG640/013/151_200/SM".$i."_L.jpg</a> </br>");
}
?>

Try something like substr ($i + 1000, 1, 4) ;)

Hans Kilian
December 27th, 2004, 04:00 PM
<?php
for ($i=001; $i <= 200; $i++) {
printf("%03d <br>", $i);
}
?>

OKtrust
December 28th, 2004, 01:40 PM
yeahh ! that's all I need
here is my code:



<?
for ($i=001; $i <= 200; $i++) {
printf ("<a href='http://www.dns.tlw.cn/3/JPEG640/053/001_050/CD%03d_L.jpg'>http://www.dns.tlw.cn/3/JPEG640/053/001_050/CD%03d_L.jpg</br>", $i ,$i);
}
?>