Hi i have a txt file like 
[SUBSTRAT]
TYP=25x25_10
SUBSTRATNAME=S112
PIXEL=5
OPERATOR=Zi
KOMMENTAR=dunkel
INTENSITAET=1000.000000
[MESSUNG]
DATUM=03.01.2005
UHRZEIT=11:22
MESSUNG=SWEEP_UI
 
i want to delete lines which start with '[' and 'TYP'. i have multiple such 
files.i have used strstr method. i have written code for it, but it results in 
deletion of complete data from files. Can anyone check where the logic goes 
wrong.
here is my file.
<?
$del_lines=array("[","TYP","P_MPP","I_MPP","V_MPP","T=","FIT","INTENSITAET");
$dir=getcwd();
$handle = opendir($dir);
while (false !== ($file = readdir($handle))) {
  if ((preg_match('/^2005\d{4}_\d{4}\.txt$/', 
$file))||(preg_match('/^2005\d{4}_\d{4}\_01_01\.txt$/',$file))){
     $fc=file($file);
     $f=fopen($file,"w");
     foreach($fc as $line){
      $bool=TRUE;
     for($i=0;$i<sizeof($del_lines);$i++){
          if(!strstr($line,$del_lines[$i])){
            $bool=FALSE;}
             break;
           //fputs($f,$line);
        }
    //if($bool){fputs($f,$line);}
   }
   if($bool){fputs($f,$line);}
fclose($f);
    } 
}
closedir($handle);
?>
 

                
---------------------------------
Yahoo! Messenger NEW - crystal clear PC to PCcalling worldwide with voicemail

Reply via email to