Jump to content


Extracting part of a webpage

  • Please log in to reply
No replies to this topic

#1 Serenissima

  • New Members
  • Pip
  • Newbie
  • 1 posts
  • LocationDerbyshire Peak District, UK

Posted 01 September 2004 - 02:07 PM


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....m/thepage.htm";
$fp = fopen($webpage,"r");
$page ="";
while (!feof($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?

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users