PHP code example of mulertech / file-manipulation

1. Go to this page and download the library: Download mulertech/file-manipulation 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/ */

    

mulertech / file-manipulation example snippets


php composer.phar update

php composer.phar 

$phpFile = new Php('path/to/file.php');
$content = $phpFile->open();

$phpFile = new Php('path/to/file.php');
$className = $phpFile->getClassName();

$phpFile = new Php('path/to/file.php');
$classNames = $phpFile->getClassNames();

$file = new FileManipulation('path/to/file'); // if for example php file : new Php('path/to/file.php')
$firstOccurrence = $file->getFirstOccurrence('string');

$file = new FileManipulation('path/to/file'); // if for example php file : new Php('path/to/file.php')
$lastOccurrence = $file->getLastOccurrence('string');

$file = new FileManipulation('path/to/file'); // if for example php file : new Php('path/to/file.php')
$lineNumber = $file->getLine(number);

$file = new FileManipulation('path/to/file'); // if for example php file : new Php('path/to/file.php')
$lines = $file->countLines();

$file = new FileManipulation('path/to/file'); // if for example php file : new Php('path/to/file.php')
$file->insertContentAtLineNumber('content', 2);