html_table関數(shù)
html_table 関數(shù):
#カスタム関數(shù) html_table は、配列內のデータを HTML テーブルに入力します。cols 屬性は、テーブルの列數(shù)を決定します。
table_attr、tr_attr、および td_attr 屬性は、テーブル內の tr タグと td タグの追加屬性を決定します。
If tr_attr
Trailpad 屬性が指定されている場合、一部のデータは最後の行に追加されます。テーブルの最後。
eg:
index.php:
require('Smarty.class .php');
$smarty = 新しい Smarty ;
$smarty->assign('data',array(1,2,3,4,5,6,7,8,9));
$smarty->assign('tr' ,array('bgcolor="skyblue"','bgcolor="#0f0"'));
$smarty->display('index.tpl' );
index.tpl:
{html_table ループ=$data}
{html_table ループ=$data Cols=4 table_attr='border="0"'}
{html_table ループ=$datacols=4 tr_attr =$tr}
出力:
: