array(1,2,3),"b"=>array("c"=>array("d"=>array("e"=>"Tom""/> array(1,2,3),"b"=>array("c"=>array("d"=>array("e"=>"Tom"">
Home > Backend Development > PHP Tutorial > [难]smarty 模板的数组这样好像完全等价, 为什么呢?解决思路

[难]smarty 模板的数组这样好像完全等价, 为什么呢?解决思路

WBOY
Release: 2016-06-13 13:27:26
Original
812 people have browsed it

[难]smarty 模板的数组这样好像完全等价, 为什么呢?
$arr = array("a"=>array(1,2,3),"b"=>array("c"=>array("d"=>array("e"=>"Tom","f"=>"BeiJing"))));
$smarty->assign("A",$arr);
$smarty->display("testTwo.html");


HTML code



{$A['b'].c['d'].e}

{$A['b'].c['d'].e} {$A['b'].c['d'].e} {$A.b.c.d.e}

a.b ==a['b'] 

http://topic.csdn.net/u/20120612/22/8610da65-573c-462e-b4b6-2175551441b0.html

------解决方案--------------------
确实,这三种情况在smarty中都可被解析:

HTML code

{$A['b'].c['d'].e}<br>            <!-- Tom -->
     {$A.b.c.d.e}<br>                  <!-- Tom -->
     {$A['b']['c']['d']['e']}<br>    <!-- Tom -->
<br><font color="#e78608">------解决方案--------------------</font><br>
smarty模板中的变量<br>可以是关联变量,用‘.’联接,‘.’前面总是要包含后面的。<br>可以是数字变量,如$A[0][1],当然也可换成键值$A['key1']['key2']<br><br><br>具体参照<br>http://0512on.com/bbs/forum.php?mod=viewthread&tid=2400&extra= <div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template