PHP code example of maximal / tsv

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

    

maximal / tsv example snippets




use Maximal\Tsv\Tsv;

// Get TSV text for the given two-dimensional data table
$tsvString = Tsv::getTsv($dataTable);
// Every cell value in `Tsv::getTsv()` call will be cast to string using `(string)$value`.
// Make sure all values are castable, e.g. all the classes have `__toString()` methods.

// Get two-dimensional data table for the given TSV text
$table = Tsv::getTable($tsvString);

// Initial two-dimensional data table
$dataTable = [[/* ... */], [/* ... */], /* ... */];
// $dataTable is `array<array<mixed>>`

// TSV text from the initial data
$tsv = Tsv::getTsv($dataTable);
// $tsv is `string`

// Data table taken back from resulting TSV text
$tableFromTsv = Tsv::getTable($tsv);
// $tableFromTsv is `list<list<string>>`

// TSV text again
$tsvFromTable = Tsv::getTsv($dataTable);
// $tsvFromTable is `string`

// `$tsv === $tsvFromTable` equality is guaranteed
// `$dataTable === $tsvFromTable` equality is NOT guaranteed