drrc61668568
drrc61668568
2012-03-27 04:22

显示文件夹中的所有图像,而不测试文件是否存在

  • image
  • php

Using the following code, I am able to display up to 10 images. What I want is to be able to display all images in the folder without going through an infinite loop and without testing if the image file exist at each loop.

for($i=1; $i<=10; $i++)
{
 $filename = "/folder/$i.jpg";
 echo "
  <img title='$i' src='$filename'>
 ";
}

Assuming that I have no idea how many images there are in the folder and that I do not want to store this information in a database, how would you display all the images with file names are that are integers ending with a .jpg extension?

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

2条回答