PHPackages                             meax/chtmltable - 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. meax/chtmltable

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

meax/chtmltable
===============

Classes for HTML Table

v2.0(10y ago)022MITHTMLPHP &gt;=5.4

Since Sep 20Pushed 10y ago2 watchersCompare

[ Source](https://github.com/mariajonsson/chtmltable)[ Packagist](https://packagist.org/packages/meax/chtmltable)[ Docs](http://mariajonsson.com)[ RSS](/packages/meax-chtmltable/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (9)Used By (0)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/d75a4da0f10b3c798216279a77ea86f4a3beb382c5e8d4265173df46bae6fff8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617269616a6f6e73736f6e2f6368746d6c7461626c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mariajonsson/chtmltable/?branch=master) [![Code Coverage](https://camo.githubusercontent.com/a25a107fe0f9316b07c06a2287c4fb8040f7a8ce05076f5c2ac4c6d5396133ba/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617269616a6f6e73736f6e2f6368746d6c7461626c652f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mariajonsson/chtmltable/?branch=master) [![Build Status](https://camo.githubusercontent.com/2531f6559ac700f79dfaf5d128e67b52cecc6e091c251e2475e887a5eb3ca178/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d617269616a6f6e73736f6e2f6368746d6c7461626c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mariajonsson/chtmltable/build-status/master)

chtmltable
==========

[](#chtmltable)

A HTML helper written in PHP to create a html table. Written for Anax-MVC.
First version includes the class `SimpleHTMLTable.php` and an example file in webroot folder, `simplehtmltable.php`.

To install with Composer and Packagist add chtmltable to your composer.json file in Anax.

```
"require": {
    "php": ">=5.4",
    "meax/chtmltable": "dev-master"
},

```

Move the example file `simplehtmltable` into your Anax installation's webroot folder.

How to build a table
--------------------

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

Method `createTable($columns, $data)`
Accepts a multiarray `$columns` representing the header row and the columns of the table.
Accepts a multiarray or object `$data` which represents the rows of the table.

**Example `$columns`**

```
$columns = array([
'name' => 'name',
'label' => 'Name',
],
[
'name' => 'id',
 'label' => 'Id',
]);

```

'name' - a value referring to a key in object or array `$data`
'label' - the label to be placed in between the tags.

**Example `$data`**

```
$data = array(
1 => [
'name' => 'Maria',
'id' => '1'
],
2 => [
'name' => 'Anon',
'id' => '2'
],
);

```

Will result in a table:

| **Name**| **Id** |
| Maria | 1 |
| Anon | 2 |

\###Creating links for column data

It is possible to create links for all cells in a column according to a linkpattern given in 'linkbase' and 'linkkey'. 'linkbase' is a static base url for the links and 'linkkey' can be defined to locate a key in the array or object `$data`.

**Example**

```
$columns = array([
  'name' => 'fruits',
  'label' => 'Fruits',

],
[
  'name' => 'animals',
  'label' => 'Animals',
  'linkbase' => 'https://en.wikipedia.org/wiki/',
  'linkkey' => 'animals',

],
);

$data = array(
  1 => [
  'fruits' => 'Apple',
  'animals' => 'Horse'
   ],
  2 => [
  'fruits' => 'Banana',
  'animals' => 'Monkey'
   ],
);

```

\###Converting column data

With the help of the method `getDisplayVal($val, $displaytype, $format)` it is possible to convert values from the array/object `$data` into another display value. This version supports converting true/false, 1/0, emtpy/not empty into simply "Yes" or "No". It also supports converting a date string into another date format.

```
$columns = array([
  'name' => 'date',
  'label' => 'Date',
  'display' => 'convert-datestr',
  'displayformat' => 'Y-m-d',
],
[
  'name' => 'title',
  'label' => 'Title',

],
[
  'name' => 'published',
  'label' => 'Published',
  'display' => 'yes-no',
],
);

$data = array(
  1 => [
  'date' => '2015-05-15 12:14',
  'title' => 'A blog post',
  'published' => true,
   ],
  2 => [
  'date' => '2015-05-16 13:15',
  'title' => 'Another post',
  'published' => false,
   ],
);

```

Have a look at the example file simplehtmltable.php to see what creating links and converting data looks like.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 93.1% 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 ~4 days

Total

4

Last Release

3880d ago

Major Versions

v1.1 → 2.x-dev2015-09-27

### Community

Maintainers

![](https://www.gravatar.com/avatar/f6ccca777317c844299ece9c582619fc03e473e6617c046de2d3404c1f08badf?d=identicon)[Meax](/maintainers/Meax)

---

Top Contributors

[![mariajonsson](https://avatars.githubusercontent.com/u/9866145?v=4)](https://github.com/mariajonsson "mariajonsson (54 commits)")[![scrutinizer-auto-fixer](https://avatars.githubusercontent.com/u/6253494?v=4)](https://github.com/scrutinizer-auto-fixer "scrutinizer-auto-fixer (4 commits)")

---

Tags

htmleducationtables

### Embed Badge

![Health badge](/badges/meax-chtmltable/health.svg)

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

###  Alternatives

[spatie/laravel-html

A fluent html builder

8376.4M72](/packages/spatie-laravel-html)[caxy/php-htmldiff

A library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

21320.9M15](/packages/caxy-php-htmldiff)[yajra/laravel-datatables-html

Laravel DataTables HTML builder plugin

2899.6M48](/packages/yajra-laravel-datatables-html)[voku/html-min

HTML Compressor and Minifier

1804.7M39](/packages/voku-html-min)[mkalkbrenner/php-htmldiff-advanced

An add-on for the php-htmldiff library for comparing two HTML files/snippets and highlighting the differences using simple HTML.

3517.8M1](/packages/mkalkbrenner-php-htmldiff-advanced)

PHPackages © 2026

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