Advertisement
qwidjib0

Trim CSS, HTML, JS

Jun 15th, 2016
427
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.48 KB | None | 0 0
  1. <?
  2.  
  3. $filename = "all.txt";  // File name here
  4.  
  5. // Trim it
  6. $myfile = fopen($filename, "r") or die("Unable to open file!");
  7. $text = fread($myfile,filesize($filename));
  8. $text = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $text);
  9. $text = preg_replace('#<style(.*?)>(.*?)</style>#is', '', $text);
  10. $text = strip_tags($text);
  11.  
  12. // Save it
  13. $newfile = fopen("trimmedtext.txt", "w") or die("Unable to open file!");
  14. fwrite($newfile, $text);
  15. fclose($myfile);
  16. fclose($newfile);
  17.  
  18. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement