1. Go to this page and download the library: Download hhpack/file 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/ */
hack
use HHPack\File\FileLineStream;
use HHPack\File\ParsedChunkStream;
use HHPack\File\ParseSpecification;
final class CustomRecordSpecification implements ParseSpecification<array<string>>
{
public function parse(Chunk $line) : array<string>
{
return $line->split(',');
}
}
$spec = new CustomRecordSpecification();
$lineStream = FileLineStream::fromString(__DIR__ . '/example.csv');
$csvStream = new ParsedChunkStream($lineStream, $spec);
foreach ($csvStream as $values) {
echo $values[0], "\n";
echo $values[1], "\n";
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.