1. Go to this page and download the library: Download adinan-cenci/file-editor 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/ */
adinan-cenci / file-editor example snippets
use AdinanCenci\FileEditor\File;
$file = new File('my-file.txt');
$search->condition('lineNumber', 10, '=');
// Will match the 11th line in the file.
$search->condition('content', ['Iliad', ' Odyssey'], 'IN');
// Will match lines that match either "Iliad" or "Odyssey"
// ( case insensitive ).
$search->condition('content', 'foo', 'LIKE');
// Will match lines that contains the word "foo"
// e.g: "foo", "foo bar", "foofighters" etc ( case insensitive ).
$search->condition('content', ['foo', 'bar'], 'LIKE');
// It also accept arrays. This will match match
// "fool", "barrier", "barista" etc.
$search->condition('content', '#\d{2}\/\d{2}\/\d{4}#', 'REGEX');
// Will match lines against a regex expression.
$search
->condition('content', 'Iliad', '!=') // Different to ( case insensitive ).
->condition('content', ['Iliad', ' Odyssey'], 'NOT IN') // case insensitive.
->condition('length', [10, 50], 'NOT BETWEEN')
->condition('content', ['foo', 'bar'], 'UNLIKE');
$search = $file->search();
$search
->condition('content', 'Iron Maiden', '=')
->condition('lineNumber', 2000, '<');
$results = $search->find();
// Will match entries for Iron Maiden, before the line 2000.
$search = $file->search('OR');
$search
->condition('content', 'Blind Guardian', '=')
->condition('content', 'Demons & Wizards', '=');
$results = $search->find();
// Will match entries for both Blind Guardian and Demons & Wizards.
$search = $file->search('OR');
$search->andConditionGroup()
->condition('content', 'Angra', '=')
->condition('lineNumber', 2010, '<');
$search->andConditionGroup()
->condition('content', 'Almah', '=')
->condition('lineNumber', 2010, '>');
$results = $search->find();
// Will match entries for Angra from before line 2010 OR
// entries for Almah from after that
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.