Associative arrays
You can also reference associative array variables that are assigned from PHP by specifying the key after the '.' (period) symbol.
Example 4-2. accessing associative array variables
index.php: $smarty = new Smarty; $smarty->assign('Contacts', array('fax' => '555-222-9876', 'email' => 'zaphod@slartibartfast.com', 'phone' => array('home' => '555-444-3333', 'cell' => '555-111-1234'))); $smarty->display('index.tpl'); index.tpl: {$Contacts.fax} {$Contacts.email} {* you can print arrays of arrays as well *} {$Contacts.phone.home} {$Contacts.phone.cell} OUTPUT: 555-222-9876 zaphod@slartibartfast.com 555-444-3333 555-111-1234
|
|