<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                <table summary="Header navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><th colspan="3" align="center">Smarty - the compiling PHPtemplate engine</th> </tr><tr><td width="25%" align="left" valign="bottom"><a href="api.functions.html" accesskey="P">Prev</a></td> <td width="50%" align="center" valign="bottom">Chapter 13. Smarty Class Methods()</td> <td width="25%" align="right" valign="bottom"><a href="api.append.by.ref.html" accesskey="N">Next</a></td> </tr></tbody></table> # append()[添加] Name 函數名稱 append() ― append an element to an assigned array 在指定數組中添加一個元素。 Description 描述 void append(mixed var); void append(string varname, mixed var, bool merge); If you append to a string value, it is converted to an array value and then appended to. You can explicitly pass name/value pairs, or associative arrays containing the name/value pairs. If you pass the optional third parameter of TRUE, the value will be merged with the current array instead of appended. 如果添加的是一個字符串,該字符串會被轉換為數組格式后再進行添加。所添加的數據可以采用名/值對的格式,或者采用包含名/值對的關聯數組格式。如果第三個可選參數被指定為TRUE,所添加的值會和數組中現有元素進行合并,而不是直接添加。 <table width="80%" border="0" cellpadding="2" cellspacing="2" class="note"><caption> 技術提示 </caption> <tr><td><p><b>Technical Note: </b> The merge parameter respects array keys, so if you merge two numerically indexed arrays,they may overwrite each other or result in non-sequential keys. This is unlike the PHP array_merge() [http://php.net/array_merge] function which wipes out numerical keys and renumbers them.</p> <p>使用第三個參數“merge”涉及到數組鍵,所以,如果添加和被添加的數組都是以數字為索引,他們會互相覆蓋,或者產生不連續的索引。這并不象PHP中的<a href="http://php.net/array_merge">array_merge()</a>函數,后者會刪除原有的數字索引,重新對索引進行編號。</p></td> </tr></table> <table class="EXAMPLE" cellspacing="0" cellpadding="0" border="0" width="100%"><tbody><tr><td><div class="EXAMPLE"> <a name="AEN3131" id="AEN3131"> </a> <b>Example 13-1. append()<br/></b> <table width="100%" bgcolor="#e0e0e0" border="0"><tbody><tr><td><p>&lt;?php<br/> // This is effectively the same as assign()<br/> $smarty-&gt;append('foo', 'Fred');<br/> // After this line, foo will now be seen as an array in the template<br/> $smarty-&gt;append('foo', 'Albert');</p> <p>$array = array(1 =&gt; 'one', 2 =&gt; 'two');<br/> $smarty-&gt;append('X', $array);<br/> $array2 = array(3 =&gt; 'three', 4 =&gt; 'four');<br/> // The following line will add a second element to the X array<br/> $smarty-&gt;append('X', $array2);</p> <p>// passing an associative array<br/> $smarty-&gt;append(array('city' =&gt; 'Lincoln', 'state' =&gt; 'Nebraska'));<br/> ?&gt;</p> </td> </tr></tbody></table><p><strong>譯者例:關于第三個參數'merge'</strong></p> <table width="100%" bgcolor="#e0e0e0" border="0"><tbody><tr><td><p>上面提到'merge'涉及到數值合并的問題,這主要是針對添加的同是數組的情況:<br/> test.php:<br/> include_once('../libs/Smarty.class.php');<br/> $smarty = new Smarty;<br/> $smarty-&gt;assign('arr',array(1,2,3));<br/> $smarty-&gt;append('arr',array(4),true);<br/> $smarty-&gt;display('test.html');<br/><br/> test.html:<br/> {foreach $arr as $i}<br/>{$i}、<br/>{/foreach}<br/><br/><br/> 輸出:4、2、3、</p> <p>將$smarty-&gt;append('arr',array(4),true);中的;;‘merge’的true參數改false則會完成添加:<br/> 1、2、3、Array、</p> </td> </tr></tbody></table></div></td> </tr></tbody></table> <table summary="Footer navigation table" width="100%" border="0" cellpadding="0" cellspacing="0"><tbody><tr><td width="33%" align="left" valign="top"><a href="api.functions.html" accesskey="P">Prev</a></td> <td width="34%" align="center" valign="top"><a href="index.html" accesskey="H">Home</a></td> <td width="33%" align="right" valign="top"><a href="api.append.by.ref.html" accesskey="N">Next</a></td> </tr><tr><td width="33%" align="left" valign="top">Smarty Class Methods()<br/> Smarty類方法 </td> <td width="34%" align="center" valign="top"><a href="api.functions.html" accesskey="U">Up</a></td> <td width="33%" align="right" valign="top">appendByRef()<br/> 引用添加 </td> </tr></tbody></table>
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看