Jump to content

Regex help


loquela

Recommended Posts

Can't really give you a suggestion about how to get your list of files into the $files array below unless you provide more details....but this should do the trick (I suggest you make backups first):

$files = array('file1.html','file2.html','file3.html');
foreach($files as $file) {
  $file = file_get_contents($file);
  $file = preg_replace('^.*?</head>(.*?)</html>(.*)$~is','$1$2',$file);
  file_put_contents($file);
}

 

You might (probably will) also need to use set_time_limit or something to keep your script from timing out.

Link to comment
https://forums.phpfreaks.com/topic/208183-regex-help/#findComment-1088162
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.