PHP code example of filmtools / parser
1. Go to this page and download the library: Download filmtools/parser 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/ */
filmtools / parser example snippets
use FilmTools\Parser\ParserFactory;
use FilmTools\Parser\ParserExceptionInterface;
$factory = new ParserFactory;
try {
$parser = $factory("data.csv");
}
catch (ParserExceptionInterface $e) {
echo $e->getMessage();
// "Invalid file extension ..."
}
try {
$records = $parser->parse("data.csv");
$records = $parser->parseString( file_get_contents("data.csv"));
foreach($records as $row):
// Do things with \Traversable
endforeach;
}
catch (ParserExceptionInterface $e) {
echo $e->getMessage();
// "File not found ..."
// or s.th. like that
}