Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. function uncomment_file($file)
  2. {
  3.    if(is_file($file))
  4.    {
  5.       $strip_regex = array
  6.       (
  7.          '#/\*.*\*/#s',
  8.          '#(^|\n)//.*#',
  9.          '/(^|\n)#.*/'
  10.       );
  11.            
  12.       $con = file_get_contents($file);
  13.       foreach($strip_regex as $regex)
  14.       {
  15.          $con = preg_replace($regex, '', $con);
  16.       }
  17.       file_put_contents($file, $con);
  18.    }
  19.    elseif(is_dir($file))
  20.    {
  21.       $han = opendir($file);
  22.       while(($f = readdir($file)) !== false)
  23.       {
  24.          if($f != '.' && $f != '..')
  25.          {
  26.             uncomment_file("{$file}/{$f}");
  27.          }
  28.       }
  29.       closedir($han);
  30.    }
  31.    return true;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement