1. Go to this page and download the library: Download hasan-22/open 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/ */
hasan-22 / open example snippets
$file = \Open\Open::ready();
$result = $file->open('file.txt')
->append('word','word1')
->appendTo('word2',1)
->prepend('word3','word4')
->prependTo('word5',2)
->clean()
->write();
or
We want to add text to our file and then receive a array output
$result = $file->open('file.txt')
->append('word','word1')
->appendTo('word2',1)
->prepend('word3','word4')
->prependTo('word5',2)
->clean()
->write()->readLines();
print_r($result);
Sample output
[
[0] => word3
[1] => word4
[2] => word5
[3] => word
[4] => word1
[5] => word2
]