Jump to content

Archived

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

Serenissima

Extracting part of a webpage

Recommended Posts

Hi,

 

I have a Dreamweaver templete with named editable regions. I want to use php to extract the information that has been put into the editable region.

 

I have got the code for a page into a variable using the following:

 

$webpage = "http://www.mydomain.com/thepage.htm";

$fp = fopen($webpage,"r");

$page ="";

while (!feof($fp))

$page.=fgets($fp,1000);

fclose($fp);

 

And on the page is a chunk of code starting <!-- #BeginEditable "title" -->

I want to retrieve the code that follows as far as <!-- #EndEditable -->

 

I tried exploding $page into an array of words thusly:

$page_array = explode(" ",$page);

 

and had thought of looping through the array until I found #BeginEditable "title" then pulling out the following array elements until I got to #EndEditable, but for some reason the #BeginEditable isn't matching (if I loop through and echo each array element it doesn't appear. But if I echo $page and look at the source html it is!).

 

I can find the position within the string of where it starts (using strpos) but as I don't know how long the code will be until the #EndEditable I can't use substr to pull it out.

 

Does anybody have any ideas please?

 

 

 

Share this post


Link to post
Share on other sites

×

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.