note 20902 added to function.fopen

From: Date: Sun, 21 Apr 2002 02:42:01 +0000
Subject: note 20902 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-29624@lists.php.net to get a copy of this message
The example of appending to a file that is listed above states that you can append to a top of a file using $fp=fopen("file.txt", "aw"); is completely wrong! It will just append to the file. Here's a working method of how to add information to the top of your file: $a="content"; $file=join(" ",file("file.txt")); $fp=fopen("file.txt","w"); fputs($fp,$a); fputs($fp, $file); fclose($fp); Now if we could just get a "p" mode in fopen(), that would rock. *hint hint* -- http://www.php.net/manual/en/function.fopen.php http://master.php.net/manage/user-notes.php?action=edit+20902 http://master.php.net/manage/user-notes.php?action=delete+20902 http://master.php.net/manage/user-notes.php?action=reject+20902

« previous php.notes (#29624) next »