8ctopus/array-to-table

php array to bootstrap 5 table

0.2.0 2023-12-28 12:09 UTC

This package is auto-updated.

Last update: 2024-10-26 15:18:55 UTC


README

packagist downloads min php version license tests code coverage badge lines of code

Convert php array to Twitter bootstrap 5 table.

install and demo

composer require 8ctopus/array-to-table
<?php

declare(strict_types=1);

use Oct8pus\ArrayToTable\ArrayToTable;

require_once __DIR__ . '/vendor/autoload.php';

$data = [
    [
        'id' => 1,
        'firstName' => 'John',
        'transactionId' => 'A1-2019',
        'refunded' => 0,
        'purchaseDate' => '2019-12-01 00:00:00',
        'expiryDate' => '2020-12-01 00:00:00',
    ], [
        'id' => 2,
        'firstName' => 'Mark',
        'transactionId' => 'A1-2020',
        'refunded' => 0,
        'purchaseDate' => '2020-12-05 00:00:00',
        'expiryDate' => '2021-12-05 00:00:00',
    ], [
        'id' => 3,
        'firstName' => 'Joe',
        'transactionId' => 'A1-2022',
        'refunded' => 1,
        'purchaseDate' => '2022-12-05 00:00:00',
        'expiryDate' => '2023-12-05 00:00:00',
    ],
];

echo (new ArrayToTable($data))
    ->render();

You can also check the example demo.php.

tests

composer test

clean code

composer fix(-risky)