note 49778 deleted from function.fopen by tularis
| From: | tularis@php.net | Date: | Mon, 26 Dec 2005 14:16:00 +0000 |
| Subject: | note 49778 deleted from function.fopen by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-100730@lists.php.net to get a copy of this message | ||
Note Submitter: rodphp - no5pam - redzia - no5pam - com
----
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);
?>