note 49778 added to function.fopen

From: Date: Tue, 08 Feb 2005 15:51:31 +0000
Subject: note 49778 added to function.fopen
Groups: php.notes 
Request: Send a blank email to php-notes+get-84667@lists.php.net to get a copy of this message
Example usage of fopen to remove line containing a key string <? $key = "w3ty8l"; //load file into $fc array $fc=file("some.txt"); //open same file and use "w" to clear file $f=fopen("some.txt","w"); //loop through array using foreach foreach($fc as $line) { if (!strstr($line,$key)) //look for $key in each line fputs($f,$line); //place $line back in file } fclose($f); ?> ---- Manual Page -- http://www.php.net/manual/en/function.fopen.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49778 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49778&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49778&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49778&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49778&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49778&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49778&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84667) next »