Quantcast
Viewing latest article 3
Browse Latest Browse All 3

php file_get_contents loop all files in same directory

I'm working on a simple comments removal script in PHP. What I'd like to do is loop this entire script for all the files in the same directory. At this point I'm not concerned with subdirectories or subfolder. This example only has 1 file. I know we need to do a do..while loop but what would be the proper syntax?

<?php$file='home.html';$page = file_get_contents($file);$current = preg_replace('<!--[^\[](.*?)-->', '', $page);file_put_contents($file, $current);echo $current;?>

I have a folder filled with *.html files so this script would read each file with the *.html extension and apply the preg_replace.

Thanks in advance!

V


Viewing latest article 3
Browse Latest Browse All 3

Trending Articles



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