note 49780 deleted from function.file by felipe
| From: | felipe@php.net | Date: | Mon, 10 Dec 2007 18:18:12 +0000 |
| Subject: | note 49780 deleted from function.file by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-133266@lists.php.net to get a copy of this message | ||
Note Submitter: redzia
----
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);
?>