PHP code example of amnl / gc-datatable

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

    

amnl / gc-datatable example snippets




/*
 * A bunch of use-statements
 * (assuming you have some kind of autoloading mechanism)
 */
use AMNL\Google\Chart\Table;
use AMNL\Google\Chart\Column;
use AMNL\Google\Chart\Row;
use AMNL\Google\Chart\Type as T;

/* The actual code */
$pizzaTable = new Table(
    new Column(new T\String(), 'Topping'),
    new Column(new T\Number(), 'Slices')
);

$pizzaTable->addRow(new Row('Mushrooms', 3));
$pizzaTable->addRow(new Row('Onions', 1));
$pizzaTable->addRow(new Row('Olives', 1));
$pizzaTable->addRow(new Row('Zucchini', 1));
$pizzaTable->addRow(new Row('Pepperoni', 2));

/* JSON Output */
header('Content-Type: application/json');
echo $pizzaTable->toJson();