gpt4 book ai didi

php - 如何使用 PEAR HTML_Table 添加 rowspan 和 colspan?

转载 作者:搜寻专家 更新时间:2023-10-31 21:07:14 28 4
gpt4 key购买 nike

$table->addRow(array("Name","Arrival Time","Departure Time","Amount"),null,"th");

我需要 2 的 rowspan 作为 Name,2 的 colspan 作为 rest。怎么做?使用 setCellAttributes()?

最佳答案

<?php
require_once("HTML/Table.php");
$attr = array("style" => "border:1px solid black;text-align:center;width:500px;height:100px;","align" => "center","border"=>1,"cellspacing"=>"0","cellpadding"=>"5");
$table = new HTML_Table($attr);
$table->addRow(array("Name", "Arrival Time","","Departure Time","", "Amount"),null, "th");
$table->addRow(array("", "AM","PM","AM","PM","Rupees","Paisa"), null,"th");
$table->setCellAttributes(0,0,"rowspan='2'");
for($i=1;$i<=5;$i++){
$table->setCellAttributes(0,$i,"colspan='2'");
}
$table->addRow(array("Toyota","4","","","6","80","50"),null);
$table->addRow(array("Toyota","","8","2","","180","30"),null);
echo $table->toHTML();
?>

您需要使用setCellAttributes() 函数并指定单元格编号

关于php - 如何使用 PEAR HTML_Table 添加 rowspan 和 colspan?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30472460/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com