Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I want to remove stuff like <![if !supportEmptyParas]> from a .doc that has been saved as a htm.
I am having problems using ereg_replace or str_replace.
When I use:Code: Select all
<?php
$filename = "deric_ortiz.htm";
if (!($fp = fopen($filename, "r+")))
{
die("cannot open ".$filename);
}
while ($data = fread($fp, 4096))
{
preg_match_all('/(<!).*?>/', $data, $matches);
foreach ($matches[0] as $match)
{
$data = ereg_replace($match, "", $data);
}
preg_match_all('/<.*?>/', $data, $matches);
foreach ($matches[0] as $match)
{
echo htmlspecialchars("$match ");
}
}
fclose($fp);
?>Basically my issue is that ereg_replace or str_replace is not actually replacing anything. Could this be an issue with how my web server is setup?
Anyone have any ideas?
After messing with this a bit more it just seems like I can't edit $data...is that because the variable is reading a file? If so how can I go about reading a file and creating a modified output from the file read? For instance what I want to do here is simply remove <! > tags and the stuff within them...it doesn't work at all because if I comment out the ('/<! ... ) preg match and the corresondping for each the output is exactly the same...I just get all the html tags... it doesn't clean out the tags I want at all...they appear too.
ANy ideas?
I am stumped.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]