php - Add new line to existing TXT file using SplFileObject -


i have txt file , neede open , add new line @ end. i'm using splfileobject:

$file = new splfileobject( $this->filename 'w' ); $file->fwrite( 'my text' . php_eol ); 

but deletes file content , saves 'my text' inside.

solved

i replaced 'w' flag 'a' flag. 'w' open file place pointer @ beginning, while 'a' place pointer @ end.

thanks @andrewsi solution.

i replaced 'w' flag 'a' flag. 'w' open file place pointer @ beginning, while 'a' place pointer @ end.

thanks @andrewsi solution.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -