Array indexes
You can reference arrays by their index, much like native PHP syntax.
Example 4-3. accessing arrays by index |
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> |