1. Go to this page and download the library: Download tomphp/patch-builder 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/ */
tomphp / patch-builder example snippets
use TomPHP\PatchBuilder\PatchBuffer;
use TomPHP\PatchBuilder\Types\LineNumber;
use TomPHP\PatchBuilder\Types\LineRange;
$buffer = PatchBuffer::createWithContents(file('somedata.txt'));
// Insert 2 at line 27
$buffer->insert(new LineNumber(27), array('hello', 'world'));
// Delete lines 12 to 16
$buffer->delete(LineRange::createFromNumbers(12, 16));
// Replace line 4 and 5 with a new line
$buffer->replace(LineRange::createFromNumbers(4, 5), array('hello moon'));
use TomPHP\PatchBuilder\PatchBuffer;
use TomPHP\PatchBuilder\Types\LineNumber;
use TomPHP\PatchBuilder\Types\OrignalLineNumber;
$buffer = PatchBuffer::createWithContents(file('somedata.txt'));
// Insert 2 at line 5
$buffer->insert(new LineNumber(5), array('hello', 'world'));
// Actually inserts at line 8 because 2 lines have been added before here.
$buffer->insert(new OriginalLineNumber(6), array('hello', 'moon'));