Array indexes

PHP Smarty

Smarty - the compiling PHP template engine
Prev 来源:PHP中文社区 Next

Array indexes

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>

OUTPUT:

555-222-9876<br>
[email protected]<br>
555-444-3333<br>
555-111-1234<br>

Prev 来源:PHP中文社区 Home Next
Associative arrays Up Objects