Associative arrays
相联数组

You can also reference associative array variables that are assigned from PHP by specifying the key after the '.' (period) symbol.

你同样可以引用php分配的数组变量.
指定方式是使用句号'.'

Example 4-2. accessing associative array variables
例 4-2.访问分配的数组

index.php:



$smarty = new Smarty;

$smarty->assign('Contacts',

    array('fax' => '555-222-9876',

          'email' => '[email protected]',

          'phone' => array('home' => '555-444-3333',

                           'cell' => '555-111-1234')));

$smarty->display('index.tpl');



index.tpl:



{$Contacts.fax}<br>

{$Contacts.email}<br>

{* you can print arrays of arrays as well *}

{$Contacts.phone.home}<br>

{$Contacts.phone.cell}<br>



OUTPUT:



555-222-9876<br>

[email protected]<br>

555-444-3333<br>

555-111-1234<br>