Jump to content

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?

 

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.