Quantcast
Channel: php file_get_contents loop all files in same directory - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Answer by Viktor for php file_get_contents loop all files in same directory

$
0
0
foreach (glob("*.html") as $file) {$page = file_get_contents($file);$current = preg_replace('<!--[^\[](.*?)-->', '', $page);file_put_contents($file, $current);echo $file . "<br>";}

This works. It removes all the html comments from every html file in a folder. Thanks for pointing me in the right direction!


Viewing all articles
Browse latest Browse all 3

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>