Jump to content

Starting numbers in for loop in php with 00 characters


satbir

Recommended Posts

I need for loop to display images..
..
but image name must start with 00... like 001.jpg, 002.jpg
.
I write my code like this..
for ($i = 001; $i <= 10; $i++) {

echo "<img src='Ony/Ony-Small/'.str_pad($i, 3, '0', STR_PAD_LEFT);.'.jpg' class='img-responsive mx-auto d-block center-block img-thumbnail'>";

}
..
but this is not working
..
can anybody suggest me the right way

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.