douwen1929
2015-05-05 12:21
浏览 171
已采纳

在路径php中使用变量作为文件夹名称

I am trying to make this listing website in PHP, and I've come to the part with the images. Every item on the site has an unique ID, and the images are saved in a folder with that id as a name. I have trouble displaying the images in a loop using that ID variable as a folder name in the path. Any ideas?

$files = glob("images/$id/*.*");
for ($i=1; $i<count($files); $i++)
{
    $num = $files[$i];
    echo $num;
}
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpn4073 2015-05-05 12:48
    已采纳

    Try it like this:

    $files = glob("images/" . $id . "/*.*");
    for ($i=1; $i<count($files); $i++)
    {
        $num = $files[$i];
        echo $num;
    
    已采纳该答案
    打赏 评论

相关推荐 更多相似问题