我想将某个文件夹中的所有图像加载到数组中,然后在Smarty的页面上显示它。显示来自Array with Smarty的所有图片
所以我所做的就是这个
$getAllImages = glob("images/profile/" . $userid . "/*.*");
$smarty->assign('images', $getAllImages);
注:当我做这个
for($i = 0; $i < sizeof($getAllImages); $i++)
echo $getAllImages[$i];
我得到这样"images/profile/1/avatar.png"
文件的图像路径我想什么现在是将其显示在我的.html页面上,以便我可以显示所有图像
我已经做NE这一点,但它似乎没有工作
{foreach from=images item=res}
<img src="{$res}">
{/foreach}
这只成果转化<img src="images">
请与手工双重检查:http://www.smarty.net/docsv2/en/language.function。 foreach - 你可能只是有一个错字(可能缺少美元符号?)。 – hakre 2013-05-05 10:06:12
提示:'from = images' - 在'images'之前缺少'$' – 2013-05-05 10:08:20