note 49780 added to function.file

From: Date: Tue, 08 Feb 2005 15:55:47 +0000
Subject: note 49780 added to function.file
Groups: php.notes 
Request: Send a blank email to php-notes+get-84669@lists.php.net to get a copy of this message
Example usage of file 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.file.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+49780 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49780&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49780&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49780&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49780&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49780&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+49780&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#84669) next »