html_table函數

html_table函數:

自訂函數 html_table 將陣列中的資料填入HTML 表格中.cols 屬性決定表格有多少列.

table_attr , tr_attr 和td_attr 屬性決定表格中tr 和td 標籤的一些附加屬性. 

如果tr_attr 和td_attr 屬性值為數組,將輪流使用其中的值. 

如果指定了trailpad 屬性,將在表尾最後一行附加一些資料.

#eg:

index.php:
#require('Smarty.class.php');
$smarty = new 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 loop=$data}
{html_table loop=$data cols=4 table_attr='border="0"'}
{html_table loop=$data cols=4 tr_attr =$tr}

輸出:

:微信图片_20180313123801.png

繼續學習
||
<?php echo "html_table函数";
關於我們 免責聲明 Sitemap
PHP中文網:公益線上PHP培訓,幫助PHP學習者快速成長!