显示所有来自Array with Smarty的图像[关闭]

I want to load all images from a certain folder into an array and then display it with Smarty on my page.

So what I've done is this

$getAllImages = glob("images/profile/" . $userid . "/*.*");
$smarty->assign('images', $getAllImages);

Note: When I do this

for($i = 0; $i < sizeof($getAllImages); $i++)
echo $getAllImages[$i];

I get the image path of the files like "images/profile/1/avatar.png"

What I want to now is to display it on my .html-page so I can display all images

I've done this, but it doesn't seem to work

{foreach from=images item=res}
  <img src="{$res}">
{/foreach}

This only results into <img src="images">

When you assign a variable in smarty it has to be access in .tpl using $ symbol hence change your code to this

{foreach from=$images item=res}

You have assigned images as a variable. so you have to use $images in tpl file

{foreach from=$images item=res}
  <img src="{$res}">
{/foreach}

For more details Check foreach manual