Simple use of arrays
Smarty's use of arrays: array[subscript], array.subscript
Modify the test.php file:
<?php require "./libs/Smarty.class.php"; $smarty = new Smarty; $smarty->assign('address', array('0', '1', array('2--0', '2--1'))); $smarty->display('./templates/test.html');
Modify test.html:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>test</title> </head> <body> <!--html的注释--> {*smarty模板的注释*} <!--{assign var='add' value='m.sbmmt.com'}--> 我们网站的网址是:{$address[2][0]}<br> 我们网站的网址是:{$address.2.0} </body> </html>
is displayed as follows: