PHPackages                             samoussa/phphtmltable - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. samoussa/phphtmltable

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

samoussa/phphtmltable
=====================

manipulate html tables in php

1.0.3(7y ago)0977MITPHPPHP &gt;=7.0

Since Aug 13Pushed 7y ago1 watchersCompare

[ Source](https://github.com/samoussa/phphtmltable)[ Packagist](https://packagist.org/packages/samoussa/phphtmltable)[ RSS](/packages/samoussa-phphtmltable/feed)WikiDiscussions master Synced 3d ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

[![Build Status](https://camo.githubusercontent.com/1707d7468c34da952a018d701a6d4d99d3db333ef11175bc1e8aae23e8fce298/68747470733a2f2f7472617669732d63692e6f72672f73616d6f757373612f70687068746d6c7461626c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/samoussa/PhpHtmlTable) [![Coverage Status](https://camo.githubusercontent.com/9a23b714af4bbdc7b13276d8bcc0cbe261f6788fbd4992101171a1c44c10de8f/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f73616d6f757373612f50687048746d6c5461626c652f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/samoussa/PhpHtmlTable?branch=master)

PHP HTML TABLE
==============

[](#php-html-table)

This repository allows to manipulate html tables in php

Concepts
--------

[](#concepts)

The project covers these concepts:

[https://www.w3schools.com/html/html\_tables.asp](https://www.w3schools.com/html/html_tables.asp)

Requirements
------------

[](#requirements)

PHP 7.0 or higher.

Installation
------------

[](#installation)

Include repositroy in your project by adding it to your composer.json file.

```
composer require samoussa/phphtmltable

```

Usage
-----

[](#usage)

### HTML Table - Adding a Caption

[](#html-table---adding-a-caption)

```
$table = new \Samoussa\PhpHtmlTable\table();
$table->setCaption("My table")
    ->addTr([1, "2", "tree"])
    ->addTr([4, "5", ["six",["style" => "color:red;"]]])
    ->render(true);
```

### Defining an HTML Table

[](#defining-an-html-table)

```
$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);
```

### HTML Table - Cells that Span Many Columns

[](#html-table---cells-that-span-many-columns)

```
$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);
```

### HTML Table - Cells that Span Many Rows

[](#html-table---cells-that-span-many-rows)

```
$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);
```

### A Special Style for One Table (Exemple twitter bootstrap) 3

[](#a-special-style-for-one-table-exemple-twitter-bootstrap-3)

```
$table = new \Samoussa\PhpHtmlTable\table(['class' => 'table table-striped']);
$table->addTr([1, "2", "tree"])
    ->addTr([4, "5", ["six", ["style" => "color:red;"]]])
    ->render(true);
```

### Specifies a group of one or more columns in a table for formatting

[](#specifies-a-group-of-one-or-more-columns-in-a-table-for-formatting)

```
$table = new \Samoussa\PhpHtmlTable\table();
$table->addTr(new \Samoussa\PhpHtmlTable\tr(['ISBN', 'Title', 'Price']))
    ->addTr([3476896, 'My first HTML', "$53"])
    ->addTr([4, '5', "six"])
    ->colgroup()
    ->addCol(new \Samoussa\PhpHtmlTable\col(['span' => 2, 'style' => 'background-color:red']))
    ->addCol(new \Samoussa\PhpHtmlTable\col(['style' => 'background-color:yellow']));
$table->render(true);
```

```
#A Special Style for One Table (Exemple twitter bootstrap) 4
$table = new \Samoussa\PhpHtmlTable\table(["class" => "table"]);
$table->thead(['class' => 'thead-light'])
    ->addTr(
        [
            new \Samoussa\PhpHtmlTable\th('#', ['scope' => "col"]),
            new \Samoussa\PhpHtmlTable\th('First', ['scope' => "col"]),
            new \Samoussa\PhpHtmlTable\th('Last', ['scope' => "col"]),
            new \Samoussa\PhpHtmlTable\th('Handle', ['scope' => "col"]),
        ]
    );
$table->tbody()
    ->addTr([new \Samoussa\PhpHtmlTable\th('1', ['scope' => "col"]), 'Mark', 'Otto', '@mdo'])
    ->addTr([new \Samoussa\PhpHtmlTable\th('2', ['scope' => "col"]), 'Jacob', 'Thornton', '@fat'])
    ->addTr([new \Samoussa\PhpHtmlTable\th('3', ['scope' => "col"]), 'Larry', 'the Bird', '@twitter']);
$table->render(true);
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~85 days

Total

4

Last Release

2575d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6e3cd67d47c1cca9fb74150e47c755ab09daa81a9263cb5a3d4d2e487bd844af?d=identicon)[samoussa](/maintainers/samoussa)

---

Top Contributors

[![olivier-sabban](https://avatars.githubusercontent.com/u/6322328?v=4)](https://github.com/olivier-sabban "olivier-sabban (17 commits)")

---

Tags

htmlphptablephphtmltable

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/samoussa-phphtmltable/health.svg)

```
[![Health](https://phpackages.com/badges/samoussa-phphtmltable/health.svg)](https://phpackages.com/packages/samoussa-phphtmltable)
```

###  Alternatives

[okipa/laravel-table

Generate tables from Eloquent models.

56752.8k](/packages/okipa-laravel-table)[artem_c/emmet

emmet implementation for php

141.8k](/packages/artem-c-emmet)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
