i'm looking for a fonction that remove ,in a text file, a line when the line contain <chaine carac>.
Code: Select all
<?
$filename = "mytextfile.txt";
$config = file($filename);
reset ($config);
foreach ($config as $line)
{
if ( $line == "" ) next($config); # Ignore blankline
elseif ( $line == "\n" ) next($config); # Ignore newline
elseif ( strstr($line,"#")) next($config); # Ignore comments
else
{
$line = rtrim($line); # Get rid of newline characters
$line = ltrim($line); # Get rid of any leading spaces
echo $line."<br>";
}
}
?>