PHP code example of studiow / table

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

    

studiow / table example snippets


//Create a table
$table = new \Studiow\Table\Table(["class" => "widefat"]);

//Create some columns
$table->createColumn("post_id", "ID", function($post) {
            return $post->ID;
        })
        ->createColumn("post_title", "Title", function($post) {
            return $post->post_title;
        });
//Add a row, which be just about anything. Probably most of the time it will be an array or an object
$table->addRow($post);

//Add multiple rows at the same time using an array of rows
$table->addRows($posts);

//render the table
echo (string) $table;

$table->createColumn("post_title", "Title", function($post) {
            return $post->post_title;
        });

$table->addColumn(new \Studiow\Table\Column\DefaultColumn("post_title", "Title", function($post) {
    return $post->post_title;
}));

$table->addColumn(new \Studiow\Table\Column\DefaultColumn("post_title", "Title", 'post_title'));