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
Post a Comment