I'm trying to extract some text from a html file, but it only seems to work when it's all on one line. My code is:
$OpenPage = fopen($PagePath, "r") or die("Can't open file!");
$ContentsBuffer = fread($OpenPage, filesize($PagePath));
$ContentExtract = preg_match("/<pcontent>.*<\/pcontent>/", $ContentsBuffer, $aExistingContent);
fclose($OpenPage);
and then I'm print it to the screen using:
print $aExistingContent[0];
now this works fine when the html file I'm reading looks like this:
<pcontent>Welcome to this website.</pcontent>
but if I insert a new line (pressing the enter key) anywhere in that passage (even just before the end tag), the preg_match fails completely.
I saw on a post when I did a search that I can use the 's' of regexp? but that didn't make any sense.
Using the .* pattern in my expression which will catch all characters, I presumed this would also be for line breaks, but it's not!
Can anyone help me solve this?
Thanks in advance