Array indexes
数组下标

You can reference arrays by their index, much like native PHP syntax.

你可以由数组索引(下标)引用数组元素,非常像php的语法.

Example 4-3. accessing arrays by index
例 4-3.由索引(下标)访问数组元素

index.php:

$smarty = new Smarty;
$smarty->assign('Contacts',
    array('555-222-9876',
          'zaphod@slartibartfast.com',
          array('555-444-3333',
                '555-111-1234')));
$smarty->display('index.tpl');

index.tpl:

{$Contacts[0]}<br>
{$Contacts[1]}<br>
{* you can print arrays of arrays as well *}
{$Contacts[2][0]}<br>
{$Contacts[2][1]}<br>

OUTPUT:

555-222-9876<br>
zaphod@slartibartfast.com<br>
555-444-3333<br>
555-111-1234<br>