2

I have links to my images and I have put them in an array. I would like to know how to loop my images using the existing links in my array. I would want something like this to show in smarty:

<img src="meat.jpg" />
<img src="chicken.jpg" />
<img src="pork.jpg" />

This is my code now private

$_arr = array(0 => "meat.jpg",
              1 => "chicken.jpg",
              2 => "pork.jpg"
);

1 Answer 1

3

Look into manual you simply need to pass $_arr to Smarty and use foreach loop like this:

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

Your Answer

Reminder: Answers generated by Artificial Intelligence tools are not allowed on Stack Overflow. Learn more

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.