codeigniter php将表格方向更改为垂直

时间:2015-02-27 02:41:22

标签: php codeigniter

如何将表格方向从水平更改为垂直?

例如

$this->table->set_heading('Name', 'Surname');
$tabClient = $this->table->generate($client); 
echo $tabClient;

提供

Name   Surname
Mark   Mark
Greg   Greg

可以改为:

Name    Mark Greg
Surname Mark Greg

1 个答案:

答案 0 :(得分:1)

像这样改变:

    //assuming your clients array is in this structure
    $clients = array(
        array("John", "Doe"),
        array("Jane", "Smith"),
    );

    $this->load->library('table');
    $fnames[] = "<strong>Name</strong>";
    $lnames[] = "<strong>Surname</strong>";
    foreach ($clients as $client) {
        $fnames[] = $client[0];
        $lnames[] = $client[1];
    }

    $this->load->library('table');
    $this->table->add_row($fnames);
    $this->table->add_row($lnames);

    $tabClient = $this->table->generate();
    echo $tabClient;