在路径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;
}

Try it like this:

$files = glob("images/" . $id . "/*.*");
for ($i=1; $i<count($files); $i++)
{
    $num = $files[$i];
    echo $num;