Heim > Backend-Entwicklung > PHP-Tutorial > php中smarty区域循环的方法,phpsmarty区域循环_PHP教程

php中smarty区域循环的方法,phpsmarty区域循环_PHP教程

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Freigeben: 2016-07-13 09:50:56
Original
823 Leute haben es durchsucht

php中smarty区域循环的方法,phpsmarty区域循环

本文实例讲述了php中smarty区域循环的方法。分享给大家供大家参考。具体实现方法如下:

<html> 
  <head> 
    <title>Smarty Test</title> 
  </head> 
  <body> 
    <table border=1> 
      {foreach key=key1 item=item1 from=$array1} 
      <tr> 
        <td>{$key1}</td> 
        <td>{$item1}</td> 
      </tr> 
      {/foreach} 
    </table> 
  </body> 
</html> 

Nach dem Login kopieren
<&#63;php 
require 'libs/Smarty.class.php'; //包含Smarty类库文件 
$smarty = new Smarty; //创建一个新的Smarty对象 
$array1 = array(1 => "Simon", 2 => "Elaine", 3 => "Susan"); //定义数组 
$smarty->assign("array1",$array1); //对模版中的变量赋值 
$smarty->display('test3.htm'); //显示页面 
&#63;> 

Nach dem Login kopieren

另一种方法:

<html> 
  <head> 
    <title>Smarty Test</title> 
  </head> 
  <body> 
    <table border=1> 
      {section name=section1 loop=$array1} 
      <tr> 
        <td</td> 
        <td>{$array1[section1]}</td>  
      </tr> 
      {/section} 
    </table> 
  </body> 
</html> 

Nach dem Login kopieren
<&#63;php 
require 'libs/Smarty.class.php'; //包含Smarty类库文件 
$smarty = new Smarty; //创建一个新的Smarty对象 
$array1 = array(0 => "Simon", 1 => "Elaine", 2 => "Susan"); //定义数组 
$smarty->assign("array1",$array1); //对模版中的变量赋值 
$smarty->display('test10.htm'); //显示页面 
&#63;>

Nach dem Login kopieren

希望本文所述对大家的php程序设计有所帮助。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1015432.htmlTechArticlephp中smarty区域循环的方法,phpsmarty区域循环 本文实例讲述了php中smarty区域循环的方法。分享给大家供大家参考。具体实现方法如下: html...
Verwandte Etiketten:
Erklärung dieser Website
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn
Aktuelle Ausgaben
PHP-Datenerfassung?
Aus 1970-01-01 08:00:00
0
0
0
PHP-Erweiterung intl
Aus 1970-01-01 08:00:00
0
0
0
Wie man PHP gut lernt
Aus 1970-01-01 08:00:00
0
0
0
Mehrere PHP-Versionen
Aus 1970-01-01 08:00:00
0
0
0
Beliebte Tutorials
Mehr>
Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage