PHP code example of vanetten / dynamictable

1. Go to this page and download the library: Download vanetten/dynamictable 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/ */

    

vanetten / dynamictable example snippets



 = [
    ['id' => 0, 'name' => 'Henry', 'age' => 42, 'city' => 'Boulder'],
    ['id' => 1, 'name' => 'Ned', 'age' => 40, 'city' => 'Los Angeles'],
    ['id' => 2, 'name' => 'Delilah', 'age' => 43, 'city' => 'Chicago'],
];
$dt = new \VanEtten\DynamicTable($data);
$html = $dt->render();
echo $html;

$dt = new \VanEtten\DynamicTable($user->posts->toArray());
echo $dt->render();


# In the addHeader method, use {{ }} to reference any existing key.

$dt->renameHeaders(['name' => 'Full Name'])
    ->addHeader(['Action' => '<a href="delete.php?id={{id}}">Delete</a>]')
    ->headerToUpperCase()
    ->excludeHeaders('id')
    ->addTableClass('table-class')
    ->addHeaderClass('header-class')
    ->addBodyClass('body-class');