PHPackages                             vesihiisi/ctable - 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. vesihiisi/ctable

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

vesihiisi/ctable
================

A generator of HTML tables

v6.0(10y ago)019MITPHPPHP &gt;=5.4

Since Feb 17Pushed 10y ago1 watchersCompare

[ Source](https://github.com/Vesihiisi/CTable)[ Packagist](https://packagist.org/packages/vesihiisi/ctable)[ RSS](/packages/vesihiisi-ctable/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (3)Used By (0)

CTable
======

[](#ctable)

Introduction
------------

[](#introduction)

Ctable is a PHP class for generating HTML tables out of data in arrays. It was created as part of the course DV1486 Databased Web Applications with PHP and MVC framework at Blekinge Institute of Technology, Sweden.

It is intended to be used with [Anax MVC](https://github.com/mosbth/Anax-MVC), but is not dependent on it. It can be included in any other project.

How to install
--------------

[](#how-to-install)

To install CTable from Packagist, put this line in your `composer.json` file:

```
"require": {
    ...
    "vesihiisi/ctable": "dev-master"
}

```

If you're using Anax-MVC, you can use the example files included in this repository to test how CTable works with the framework. Put the pagecontroller `webroot/tables.php` and the stylesheet `css/tables.css` in your own webroot directory and point your browser to the controller.

How to use
----------

[](#how-to-use)

### How to create a table

[](#how-to-create-a-table)

The data that you want to display in a table should be an array of arrays. Each inside array corresponds to one table row. Together, all the rows are collected in an outside array:

```
$rows = array(
    array("Row 1 value 1", "Row 1 value 2", "Row 1 value 3", "Row 1 value 4",),
    array("Row 2 value 1", "Row 2 value 2", "Row 2 value 3", "Row 2 value 4",),
    array("Row 3 value 1", "Row 3 value 2", "Row 3 value 3", "Row 3 value 4",),
    array("Row 4 value 1", "Row 4 value 2", "Row 4 value 3", "Row 4 value 4",),
    array("Row 5 value 1", "Row 5 value 2", "Row 5 value 3", "Row 5 value 4",),
    );

```

Then you might want to add the table headings, also as an array. It is not necessary, though – if you fail to do so, the first row of your data will be used as headings.

```
$headers = array(
    "Header 1", "Header 2", "Header 3", "Header 4",
    );

```

You can now create the table object and feed it in your data. This is how it would be done in Anax MVC:

```
$table = new \Vesihiisi\CTable\CTable([
    'rows' => $rows,
    'headers' => $headers,
    ]);

```

Once the object is created, you can also add new rows one by one:

```
$table->addRow(["Extra row value 1", "Extra row value 2", "Extra row value 3", "Extra row value 4"]);

```

Finally, in order to actually render the table, you must use the object's View() method and display the result in your view:

```
    $app->views->add('default/page', [
    'content' => $table->View(),
    'title' => "Demonstration of tables in HTML"
]);

```

### Optional elements

[](#optional-elements)

There is a number of optional elements that you might want to add to your table.

**Footer** content can be defined before creating the object. Then, you feed it to the object, just like you did with the `$data` and `$headers` variables:

```
$footer = array(
    "Footer 1", "Footer 2", "Footer 3", "Footer 4",
    );

```

You can also define it after creating the object:

```
$table->setFooters(["Footer 1", "Footer 2", "Footer 3", "Footer 4"]);

```

**Table caption** (the `` tag) can also be created in two ways:

```
$caption = "Example data";

$table->setCaption("Example data");

```

**CSS classes and ID** can be added to the `` tag. Those can also be created in two ways:

```
$classes = array(
    "someClass",
    "anotherClass",
    );
$id = "table01";

$table->setClass(["someClass", "anotherClass"]);
$table->setID("table01");

```

License
-------

[](#license)

This software is free software and carries a MIT license.

[![Build Status](https://camo.githubusercontent.com/a81554ec3487ff8a70032b1747a56a06ad31cf91ed47a4b6906d37c621ca21c5/68747470733a2f2f7472617669732d63692e6f72672f5665736968696973692f435461626c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Vesihiisi/CTable) [![Scrutinizer Code Quality](https://camo.githubusercontent.com/a669312a6765670a3c5c3d13f0c490b15430aa31752f8e9dbbb0de0e5f322bdc/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5665736968696973692f435461626c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Vesihiisi/CTable/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/96e739ad819f9eb23460686e966c768292eb5c8fe0b98d48e8930947f9cd885b/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f5665736968696973692f435461626c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Vesihiisi/CTable/?branch=master) [![Code Climate](https://camo.githubusercontent.com/380c8343ad70858d9ac66c62af0661a28c52e7d9686001553070fe4dec348d75/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f5665736968696973692f435461626c652f6261646765732f6770612e737667)](https://codeclimate.com/github/Vesihiisi/CTable) [![Issue Count](https://camo.githubusercontent.com/bf21e5cc3a8a3e43fe204307836932d8a97d4c71f7160ec2605497da9e8364e8/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f5665736968696973692f435461626c652f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/Vesihiisi/CTable) [![Total Downloads](https://camo.githubusercontent.com/a742a19a434297c654ad42b21c2533bf6b717b50302d52748cf84b6054db5546/68747470733a2f2f706f7365722e707567782e6f72672f7665736968696973692f637461626c652f646f776e6c6f616473)](https://packagist.org/packages/vesihiisi/ctable) [![Latest Stable Version](https://camo.githubusercontent.com/57d8b6b92c1044fb393c3471254bf4a36b5c193350e7eafdbff287d57b457eed/68747470733a2f2f706f7365722e707567782e6f72672f7665736968696973692f637461626c652f762f737461626c65)](https://packagist.org/packages/vesihiisi/ctable)

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 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 ~0 days

Total

2

Last Release

3786d ago

Major Versions

v1.0 → v6.02016-02-17

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1749153?v=4)[Alicia Fagerving](/maintainers/Vesihiisi)[@Vesihiisi](https://github.com/Vesihiisi)

---

Top Contributors

[![Vesihiisi](https://avatars.githubusercontent.com/u/1749153?v=4)](https://github.com/Vesihiisi "Vesihiisi (27 commits)")

### Embed Badge

![Health badge](/badges/vesihiisi-ctable/health.svg)

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

###  Alternatives

[fpn/tag-bundle

FPN Tag Bundle

75408.0k2](/packages/fpn-tag-bundle)[tarfin-labs/laravel-spatial

Laravel package to work with geospatial data types and functions.

7496.5k](/packages/tarfin-labs-laravel-spatial)

PHPackages © 2026

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