// goodby/csvの例
$records = [];
$config = new LexerConfig();
$config
->setDelimiter(",")
->setFromCharset('SJIS-win')
->setToCharset('UTF-8') // Customize target encoding. Default value is null, no converting.
;
$lexer = new Lexer($config);
$interpreter = new Interpreter();
$interpreter->unstrict(); // Ignore row column count consistency
$interpreter->addObserver(function(array $row) use (&$records) {
$records[] = $row;
});
$lexer->parse($file_path, $interpreter);
return $records;
// League\Csvの例
$reader = Reader::createFromPath($file_path, 'r');
$filter = urlencode('convert.iconv.SJIS-win/UTF-8');
$reader->appendStreamFilter($filter);
return $reader;
}