PHP code example of struktal / struktal-csv-reader

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

    

struktal / struktal-csv-reader example snippets


$csvReader = new CSVReader();

// CSV Reader Options
$csvReader->setFile("path/to/file.csv")
          ->setHeader(false)
          ->setDelimiter(";")
          ->setMaxLineLength(null)
          ->read();

// Get the CSV Data
$data = $csvReader->getData();

[
    [
        "name",
        "age",
        "city"
    ],
    [
        "Alice",
        "25",
        "New York"
    ],
    [
        "Bob",
        "30",
        "London"
    ],
    [
        "Charlie",
        "20",
        "Berlin"
    ],
    [
        "David",
        "35",
        "Paris"
    ],
    [
        "Frank",
        "40",
        "Tokyo"
    ]
]

[
    [
        "Alice",
        "25",
        "New York"
    ],
    [
        "Bob",
        "30",
        "London"
    ],
    [
        "Charlie",
        "20",
        "Berlin"
    ],
    [
        "David",
        "35",
        "Paris"
    ],
    [
        "Frank",
        "40",
        "Tokyo"
    ]
]