{section},{sectionelse} {#language.function.section}
=======================
A `{section}` is for looping over **sequentially indexed arrays of
data**, unlike [`{foreach}`](#language.function.foreach) which is used
to loop over a **single associative array**. Every `{section}` tag must
be paired with a closing `{/section}` tag.
> **Note**
>
> The [`{foreach}`](#language.function.foreach) loop can do everything a
> {section} loop can do, and has a simpler and easier syntax. It is
> usually preferred over the {section} loop.
> **Note**
>
> {section} loops cannot loop over associative arrays, they must be
> numerically indexed, and sequential (0,1,2,\...). For associative
> arrays, use the [`{foreach}`](#language.function.foreach) loop.
   Attribute Name    Type     Required   Default  Description
  ---------------- --------- ---------- --------- -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        name        string      Yes       *n/a*   The name of the section
        loop         mixed      Yes       *n/a*   Value to determine the number of loop iterations
       start        integer      No        *0*    The index position that the section will begin looping. If the value is negative, the start position is calculated from the end of the array. For example, if there are seven values in the loop array and start is -2, the start index is 5. Invalid values (values outside of the length of the loop array) are automatically truncated to the closest valid value.
        step        integer      No        *1*    The step value that will be used to traverse the loop array. For example, step=2 will loop on index 0,2,4, etc. If step is negative, it will step through the array backwards.
        max         integer      No       *n/a*   Sets the maximum number of times the section will loop.
        show        boolean      No      *TRUE*   Determines whether or not to show this section
**Option Flags:**
    Name    Description
  --------- ------------------------------------------
   nocache  Disables caching of the `{section}` loop
-   Required attributes are `name` and `loop`.
-   The `name` of the `{section}` can be anything you like, made up of
    letters, numbers and underscores, like [PHP
    variables](&url.php-manual;language.variables).
-   {section}\'s can be nested, and the nested `{section}` names must be
    unique from each other.
-   The `loop` attribute, usually an array of values, determines the
    number of times the `{section}` will loop. You can also pass an
    integer as the loop value.
-   When printing a variable within a `{section}`, the `{section}`
    `name` must be given next to variable name within \[brackets\].
-   `{sectionelse}` is executed when there are no values in the loop
    variable.
-   A `{section}` also has its own variables that handle `{section}`
    properties. These properties are accessible as:
    [`{$smarty.section.name.property}`](#language.variables.smarty.loops)
    where "name" is the attribute `name`.
-   `{section}` properties are [`index`](#section.property.index),
    [`index_prev`](#section.property.index.prev),
    [`index_next`](#section.property.index.next),
    [`iteration`](#section.property.iteration),
    [`first`](#section.property.first),
    [`last`](#section.property.last),
    [`rownum`](#section.property.rownum),
    [`loop`](#section.property.loop), [`show`](#section.property.show),
    [`total`](#section.property.total).
[`assign()`](#api.assign) an array to Smarty
    assign('custid',$data);
    ?>
The template that outputs the array
    {* this example will print out all the values of the $custid array *}
    {section name=customer loop=$custid}
    {section customer $custid} {* short-hand *}
      id: {$custid[customer]}
    {/section}
    
      name: {$contacts[customer].name}
      home: {$contacts[customer].home}
      cell: {$contacts[customer].cell}
      e-mail: {$contacts[customer].email}
    
      name: John Smith
      home: 555-555-5555
      cell: 666-555-5555
      e-mail: john@myexample.com
    
      name: Jack Jones
      home phone: 777-555-5555
      cell phone: 888-555-5555
      e-mail: jack@myexample.com
    
      name: Jane Munson
      home phone: 000-555-5555
      cell phone: 123456
      e-mail: jane@myexample.com
    
      id: {$custid[customer]}
      name: {$name[customer]}
      address: {$address[customer]}
    
      id: 1000
      name: John Smith
      address: 253 Abbey road
    
      id: 1001
      name: Jack Jones
      address: 417 Mulberry ln
    
      id: 1002
      name: Jane Munson
      address: 5605 apple st
    
| Name> | Home | Cell | ||
|---|---|---|---|---|
| view | {$contacts[co].name} | {$contacts[co].home} | {$contacts[co].cell} | {$contacts[co].email} | 
| No items found | ||||
| index | id | index_prev | prev_id | index_next | next_id | 
|---|---|---|---|---|---|
| {$smarty.section.row.index} | {$rows[row]} | {$smarty.section.row.index_prev} | {$rows[row.index_prev]} | {$smarty.section.row.index_next} | {$rows[row.index_next]} | 
| Name> | Home | Cell | ||
|---|---|---|---|---|
| view | {$contacts[co].name} | {$contacts[co].home} | {$contacts[co].cell} | {$contacts[co].email} | 
| id | customer | 
|---|---|
| {$customers[customer].id}} | {$customers[customer].name} | 
| {$smarty.section.customer.total} customers |