Prev |  | Next

#### 1.4.4.6. LOOP

Function

  The LOOP statement is used for looping through the elements of array based template variables (for example arrays of forums, messages and users).

Syntax

  `
  {LOOP <ARRAY VARIABLE>}
  {<ARRAY VARIABLE>}
  {/LOOP <ARRAY VARIABLE>}
  `

  The `<ARRAY VARIABLE>` has to be the name of an existing template variable containing an array.

  Within the LOOP, the active array element is assigned to a variable that has the same name as the `<ARRAY VARIABLE>` that you are looping over. In our example below, we are looping over `USERS`, which is an array of user data records. Within the loop, `USERS` is no long the array of users itself, but the user data record for a single user instead.

Example code

  Example 1.18. LOOP statement usage

      <ul>
      {LOOP USERS}
        <li>{USERS->username}</li>
      {/LOOP USERS}
      </ul>

Prev | Up | Next
| Home |