1. Go to this page and download the library: Download mobileka/liner 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/ */
mobileka / liner example snippets
$liner = new Liner('path/to/a/file'); // or SplFileObject instance
// Read the whole file
$liner->read();
// Only the first line
$liner->read(1);
// Only the second line
$liner->read(1, 1);
// Read 100 lines starting with the 6th line
$liner->read(100, 5);
// You can also pass a closure as a third argument to mutate the result without iterating over it
// Here's how you can read a CSV file:
$csvAsArray = $liner->read(0, 0, function($file, $line) {
$line = trim($line);
return explode(',', $line);
});
// A line will be ignored if modifier returns null
$anEmptyArray = $liner->read(0, 0, function($file, $line) {
return null;
});
// almost forgot to mention that you can get the number of lines
$liner->getNumberOfLines();
// and that you can also delegate methods to SplFileObject (is it a good idea though?)
$liner->eof();
$liner->rewind();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.