<?php

error_reporting(-1);


  $dir = "../www/html_wind.xaxx/";
  
   $filename = glob("html_wind.xaxx/*.html");
   $numbStr = count($filename);



for ($i=0; $i<$numbStr; $i++) { 
  $fl = file($filename[$i]);
  $find_one = '<center><table';
  $find_two = '<center><a href';
  foreach ($fl as $num => $str) {
    if(strpos($str, $find_one)!==false) {
    
      $pos_findme_three = strpos($str, '<br><center>');
      $pos_findme_four = strpos($str, '</div><script');
      $newstr_three = substr($str, 0, $pos_findme_three);
      $newstr_four = substr($str, $pos_findme_four);
      $replace_2 = $newstr_three.$newstr_four;
      $fl[$num] = $replace_2;

      echo htmlspecialchars($fl[$num]);
      echo $num;
      file_put_contents($filename[$i], $fl);
     }
   }


  foreach ($fl as $num => $str) {
    if(strpos($str, $find_two)!==false) {
    
      $pos_findme_one = strpos($str, '<center><a href=');
      $pos_findme_two = strpos($str, '</script></body>');
      $newstr_one = substr($str, 0, $pos_findme_one);
      $newstr_two = substr($str, $pos_findme_two);
      $replace = $newstr_one.$newstr_two;
      $fl[$num] = $replace;

      echo htmlspecialchars($fl[$num]);
      echo $num;
      file_put_contents($filename[$i], $fl);
   }
 }
}
?>