HBcms是一个用Pear框架+Smarty模板引擎构架的cms项目,欢迎大家参与制作Smarty模板

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',
 '[email protected]',
 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>

输出结果:

555-222-9876<br>
[email protected]<br>
555-444-3333<br>
555-111-1234<br>
这是一份简单的Smarty手册和Smarty教材,熟练掌握Smarty模板,让您做项目事半功倍