Name: salehramazani Date: January 3, 2008 at 00:30:57 Pacific Subject: file_get_content command OS: W3K CPU/Ram: 3.2,2gb
Comment:
Someone posted a question here a year ago about this same topic. They had an HTML page and wanted to post a substring (first 50 or so characters) of it on another page. This problem was solved using the php file_get_content command here: http://www.computing.net/webdevel/w...
I'm trying to do the same thing but to a known portion of the text in middle of my page. In other words, I want to set a start and an end point within my page and grab only a portion of the text that I want like this:
Here's a quick and dirty solution that requires using a couple of "flags" in the source page (you need to replace the [] with <> in the first two lines):
Hey Micheal thank you for the response. I tried what you said but I keep getting a blank output in my php page. This is what I did: in a test HTML page I put (replaced [] with <>):
Unwanted text $start_text = "[!--START--]"; Wanted text.... $end_text = "[!--END--]"; Unwanted text
Do I need php markups before my start_text and after end_text lines in my HTML document? Also, I don't really get what string is being stored in the $search variable...
Unwanted text $start_text = "[!--START--]"; Wanted text.... $end_text = "[!--END--]"; Unwanted text
I'm assuming that was just a typo and you are only putting in the comment code and not the whole PHP code.
The $search variable is supposed to be the contents of the HTML file - i.e. what you are calling $source. Anyway I had a typo in my code and transposed the two variables in the strpos() functions.
I have corrected and tested the following code: HTML file (source.htm)
[html] [head][/head]
[body]
Unwanted Text [!--START--] Wanted Text [!--END--] Unwanted Text
A question. This source work as well if im using a local file, or better if the pages are used in the same server. But, what can i do when the "source.htm" is outside of the server in another website?
What i need is: Get the HTML from another page, and "cut" a part of it. To show only what i want. I do it as you say later but its working only when the page is in the same machine, and not when the page that i need get the html is outside of the machine. i hate it. x) Im working on it for a long time. =/