Please have a look at my function
| From: | Mag | Date: | Thu, 19 Aug 2004 00:11:54 +0000 |
| Subject: | Please have a look at my function | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-194217@lists.php.net to get a copy of this message | ||
Hello,
I dont know regex very well but I am using one below
that I modified from the web:
** Start code**
function RStripHeader($string) {
return eregi_replace('<!-- .*Hstart("|\')?([^
"\']*)("| \')?.*>([^<]*)<!-- Hend -->', '', $string);
}
$the_file = "something.html";
$content = RStripHeader(file_get_contents($the_file));
$fhandle = fopen($the_file, "w");
fwrite($fhandle,$content);
fclose($fhandle);
echo "Done <b>".$the_file."</b><br>";
** End code***
Basically what I am trying to do above is:
open a file
delete everything that starts with
<!-- Hstart -->
and ends with <!-- Hend -->
eg:
it will delete everything below including
"<!-- Hstart -->" and "<!-- Hend -->"
<!-- Hstart --> all this will be deleted! <!-- Hend
-->
Its working great for 1 file, but when I put it into a
for loop to handle multiple files....it takes ages for
10 files and sometimes just "hangs".
please help.
Thanks,
Mag
=====
------
- The faulty interface lies between the chair and the keyboard.
- Creativity is great, but plagiarism is faster!
- Smile, everyone loves a moron. :-)
_______________________________
Do you Yahoo!?
Express yourself with Y! Messenger! Free. Download now.
http://messenger.yahoo.com