天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

將php數組輸出html表格的方法

復制代碼 代碼如下:
<?php
class xtable
{
 private $tit,$arr,$fons,$sextra;
 public function __construct()
 {
  $this->tit=array();       // strings with titles for first row
  $this->arr=array();       // data to show on cells
  $this->fons=array("#EEEEEE","#CCEEEE");  // background colors for odd and even rows
  $this->sextra="";       // extra html code for table tag
 }

 public function extra($s)      // add some html code for the tag table
 {
  $this->sextra=$s;
 }
 public function background($arr) {if (is_array($arr)) $this->fons=$arr; else $this->fons=array($arr,$arr);}
 public function titles($text,$style="") {$this->tit=$text; $this->sesttit=$style;}
 public function addrow($a) {$this->arr[]=$a;}
 public function addrows($arr) {$n=count($arr); for($i=0;$i<$n;$i++) $this->addrow($arr[$i]);}
 public function html()
 {
  $cfondos=$this->fons;
  $titulos="<tr>";
  $t=count($this->tit);
  for($k=0;$k<$t;$k++)
  {
   $titulos.=sprintf("<th>%s</th>",$this->tit[$k]);
  }
  $titulos.="</tr>";

  $celdas="";
  $n=count($this->arr);
  for($i=0;$i<$n;$i++)
  {
   $celdas.=sprintf("<tr style='background-color:%s'>",$this->fons[$i%2]);
   $linea=$this->arr[$i];
   $m=count($linea);
   for($j=0;$j<$m;$j++)
    $celdas.=sprintf("<td  %s>%s</td>","",$linea[$j]);
   $celdas.="</tr>";
  }
  return sprintf("<table cellpadding='0' cellspacing='0' border='1' %s>%s%s</table>",$this->sextra,$titulos,$celdas);
 }
 public function example()
 {
  $tit=array("Apellidos","Nombre","Telefono");
  $r1=array("Garcia","Ivan","888");
  $r2=array("Marco","Alfonso","555");
  $x=new xtable();
  $x->titles($tit);      //take titles array
  $x->addrows(array($r1,$r2));   // take all rows at same time
  return $x->html();     //return html code to get/show/save it
 }
}


// Example
$t1=new xtable();
echo $t1->example()."<hr />";

$t2=new xtable();
for($i=1;$i<=10;$i+=2)
 {
  $t2->addrow(array("ODD",$i));
  $t2->addrow(array("EVEN",$i+1));
 }
$t2->background(array("pink","gold"));
$t2->titles(array("TYPE","#"));
$t2->extra(" style='width:500px; background-color:cyan; color:navy;'");
echo $t2->html()."<hr />";

$t3=new xtable();
for($i=1;$i<=6;$i++)
 {
  $t3->addrow(array("5x".$i,5*$i));

 }
$t3->background(array("olive","maroon"));
$t3->titles(array("Multiplication table","5"));
$t3->extra("style='border:dotted red 10px; padding-left:4px;padding-right:4px; text-align:right;width:500px; background-color:black; color:white;'");
echo $t3->html()."<hr />";

$t4=new xtable();
$a=array("#");
for($i=1;$i<=10;$i++)
 {
  $a[]=$i;
 }
$t4->addrow($a);
$t4->background(array("pink","gold"));
$tit=array(); $tit[]="Numbers";
for($i=1;$i<=10;$i++) $tit[]="#";
$t4->titles($tit);
$t4->extra("style='border:solid 1px silver; padding-left:4px;padding-right:4px; text-align:center;width:500px; background-color:cyan; color:navy;'");
echo $t4->html()."<hr />";
?>

php技術將php數組輸出html表格的方法,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 四虎永久免费 | 99久久久久精品国产免费麻豆 | 四虎影视国产精品亚洲精品 | 天美传媒在线完整免费观看网站 | 日韩专区亚洲国产精品 | 娇喘嗯嗯 轻点啊视频福利 娇喘高潮教室h | 精品一区二区三区在线成人 | 国产欧美一本道无码 | 久久永久免费视频 | 日本xxxxx按摩19 | 99国产在线观看 | 久久99蜜桃精品麻豆 | 久热久热精品在线观看 | 好男人好资源视频高清 | 青柠在线视频 | 国产在线高清亚洲精品一区 | 亚洲呦女专区 | 四虎一级片 | 丝袜美腿美女被狂躁在线观看 | 涩涩视频在线看 | 暖暖的高清视频在线观看免费中文 | 亚洲国产在线午夜视频无 | 乳色吐息未增删樱花ED在线观看 | 99热婷婷国产精品综合 | 97国产成人精品视频 | 亚洲区视频 | 里番※琉璃全彩acg奈亚子 | H厨房灌草莓 | 国产亚洲精品久久综合阿香蕉 | 亚洲国产高清福利视频 | 免费精品一区二区三区在线观看 | 青娱乐视觉盛宴国产视频 | 国产国拍亚洲精品永久软件 | 青苹果乐园在线观看电视剧 | 亚洲电影网址 | 特级淫片大乳女子高清视频 | 视频成人永久免费看 | 麻豆乱码一卡二卡三卡视频 | 91国偷自产一区二区三区 | 亚洲一区二区三不卡高清 | 亚洲444777KKK在线观看 |