Foreach Statement

Overview

The "foreach" statement works just like a foreach loop in traditional programming languages. The statement begins with <c:foreach> and ends with </c:foreach>.

Attributes

All attributes go inside the opening <c:foreach> tag, and must be surrounded by double-quotes.

select (required)

Defines the content that will be output in the loop using three parts. The first part is a variable name that can be referred to within the loop (this is any single word of your choice); the second part is always the word "in"; and the third part is a system data collection like album images, blog posts, calendar events, media episodes or comments.

Example

<c:foreach select="Comment in [c:Content.Comments]">
    <div>[c:Comment.Author]</div>
</c:foreach>