CsvIterator

Many websites must read csv files, to import customer data, to read some custom settings, etc…

We will expand this class later to set the csv options from an xml config file or a database, but for now see examples below.

To read data from a csv file, we need a csv file first. We store the below data into the file “example.csv”.

The standard csv options are:

Now we can read the data from the “example.csv”. Here are two examples to get the csv data from the file:
1. Foreach

Here is the ouput from the code above:

2. Get combined array

The output:

Demo

PROJECT_ROOT/vendor/PHPluz/CsvIterator.php

Leave a Reply