Jump to content

Parsing/Passing HTML via PHP


JasonStockman

Recommended Posts

Hello everyone,

 

I'm a very savvy programmer, and a fast learner, but I'm in need of some help here.  :-\

What I would like to do is have a PHP page that is able to extract the contents/code/source of a separate HTML page, modify it slightly, and output/echo the result (without modifying the original). I would like this PHP page to be able to apply these modifications to several different HTML pages when called upon.

 

The overall layout will involve 3 pages at any given time.

 

index.html (page with a link that opens page.php in a pop-up window)

page.php (the little guy doing all the work)

example.html (the page containing the source we want copied/modified)

 

index.html will contain a link to a pop-up window, the contents of which will be the altered form of example.html

 

All I really need is a push in the right direction with this. I thought of passing the link to the 3rd page, the page to be modified, as an argument in the URL to page.php - something like this:

Line number On/Off | Expand/Contract

 

<a href="page.php?link=example.html">See modified version in a pop-up window!</a>

 

That's really all I have so far. I am a PHP noobie, but eager to learn.

 

The task of passing example.html as a variable seems easy enough, but actually doing anything with it (parsing it I guess you would say) has left me posting here. Is PHP capable of doing this, or will I need the support of some 3rd party plugins?

 

Thanks for your help, everyone!  ;D

 

-Jason

Link to comment
https://forums.phpfreaks.com/topic/136772-parsingpassing-html-via-php/
Share on other sites

Just a quick answer gauged more towards 'pushing you in the right direction' than giving a great big answer but I'd have a good look at

 

fopen

 

Start on the page and follow through the functions it offers. Your able to put all the content of that file into a variable

 

Then you can just work on the variable with string replace of regular expressions (whatever you require)

Archived

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

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