PHP code example of terremoth / php-dsv

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

    

terremoth / php-dsv example snippets




use DSV\Writer;
use DSV\Reader;

$data = [
    ['Name', 'Comment'],
    ['Alice', 'She said, "Hello" and waved.'],
    ['Bob', 'This is a multi-line comment\r\nspanning two lines.'],
    ['Charlie', 'More fun with\ntwo lines.'],
    ['Diana', 'How about some UTF-8: café, naïve, résumé. 📝'],
    ['Edward', 'アップル'],
];

$writer = new Writer('demos/data.dsv');
$writer->write($data); // will write the $data to file in DSV format

$reader = new Reader('demos/data.dsv');
print_r($reader->read()); // will read the demos/data.dsv file and put it in array format 
shell
composer