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:

微信图片_20180312151514.png

Continuing Learning
||
<?php echo "数组的简单使用";
submitReset Code
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!