use \WidgetTable\WidgetTable; $table = new WidgetTable(); $data = [ ['name' => 'John Doe', 'age' => 25, 'gender' => 'Male'], ['name' => 'Jane Smith', 'age' => 30, 'gender' => 'Female'], ['name' => 'Bob Johnson', 'age' => 40, 'gender' => 'Male'] ]; $headers = [ 'Name', 'Age', 'Gender' ]; $table->setData($data); $table->setHeaders($headers); echo $table->render();
use \WidgetTable\WidgetTable; $table = new WidgetTable(); $data = [ ['name' => 'John Doe', 'age' => 25, 'gender' => 'Male'], ['name' => 'Jane Smith', 'age' => 30, 'gender' => 'Female'], ['name' => 'Bob Johnson', 'age' => 40, 'gender' => 'Male'] ]; $table->setData($data); $table->setHeaderCallback(function($header) { return strtoupper($header); }); $table->setDataCallback(function($value, $header) { if ($header === 'Age') { return $value . ' years'; } return $value; }); echo $table->render();In this example, we again create a new WidgetTable object and populate it with some sample data. We also provide callback functions for customizing the headers and data values in the table. In this case, we are making the headers all uppercase and adding the text "years" to the end of the age values. The package library for Widget Table is `widget-table/widget-table`.