Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $f = "test.txt";
- // read into array
- $arr = file($f);
- // add second line
- array_splice($arr,1,0, array("test line 2\r\n"));
- // reindex array
- $arr = array_values($arr);
- // write back to file
- file_put_contents($f,implode($arr));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment