PHP code example of samoussa / phphtmltable

1. Go to this page and download the library: Download samoussa/phphtmltable library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

samoussa / phphtmltable example snippets

 php 
$table = new \Samoussa\PhpHtmlTable\table();
$table->setCaption("My table")
    ->addTr([1, "2", "tree"])
    ->addTr([4, "5", ["six",["style" => "color:red;"]]])
    ->render(true);
 php 
$table = new \Samoussa\PhpHtmlTable\table(["style" => "width:100%"]);
$tr = new \Samoussa\PhpHtmlTable\tr();
$tr->addTh("Firstname")
    ->addTh("Lastname")
    ->addTh("Age");
$table->addTr($tr)
    ->addTr(["Jill", "Smith", "50"])
    ->addTr([new td("Eve"), new td("Jackson"), new td("94",["style" => "color:red;"])])
    ->render(true);
 php 
$table = new \Samoussa\PhpHtmlTable\table(["style" => "width:100%"]);
$tr = new \Samoussa\PhpHtmlTable\tr();
$tr->addTh("Name")
    ->addTh(["Telephone", ["colspan" => 2]]);
$table->addTr($tr)
    ->addTr(["Bill Gates", 55577854, 55577855])
    ->render(true);
 php 
$table = new \Samoussa\PhpHtmlTable\table(["style" => "width:100%"]);
$table->addTr([new \Samoussa\PhpHtmlTable\th('Telephone', ['rowspan' => 2]), 555778545]);
$tr = new \Samoussa\PhpHtmlTable\tr();
$tr->addTh("Name")
    ->addTd("Bill Gates");
$table->addTr($tr)
    ->addTr(['55577855'])
    ->render(true);
 php 
$table = new \Samoussa\PhpHtmlTable\table(['class' => 'table table-striped']);
$table->addTr([1, "2", "tree"])
    ->addTr([4, "5", ["six", ["style" => "color:red;"]]])
    ->render(true);