Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $filepathname = "./test.txt";
- $target = "A line after which the code should be added";
- $newline = "A new line";
- $stats = file($filepathname, FILE_IGNORE_NEW_LINES);
- $offset = array_search($target,$stats) +1;
- array_splice($stats, $offset, 0, $newline);
- file_put_contents($filepathname, join("n", $stats));
- $dir = dirname(__FILE__);
- glob_recursive($dir);
- function glob_recursive($dir){
- foreach(glob($dir."*", GLOB_NOSORT) as $filename){
- if(is_dir($filename)) glob_recursive($filename."/*");
- else{
- foreach(glob($dir."test.txt", GLOB_NOSORT) as $filename){
- echo $filename."<br>";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement