Ok I have 2 options that I need to figure one or the other out
I have $URL set to a link (ex. http://www.google.com)
Option 1:
What I need/want is to set each line of that page to a line of the array. Then i need it to select ONLY line #179 and save it as $179
Option 2:
just cut everything but line 179 of the html file. and save it as $line
Html page to array
Moderator: General Moderators
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Html page to array
Code: Select all
$buff = file_get_contents('some/html/page.html');
$lines = explode("\n", $buff);Code: Select all
$lines = file('some/html/page.html');Re: Html page to array
Thanks.
And then how do I get the specific line from that?
And then how do I get the specific line from that?
Re: Html page to array
$lines is now a 0 based (meaning the first line has index 0, the second line has index 1, and so on) array containing all the lines of the source code of the web page in question.
To access the 179rd line use this:
To access the 179rd line use this:
Code: Select all
$line179 = $lines[178];Re: Html page to array
$lines[178] or is that supposed to be 179?manixrock wrote:Code: Select all
$line179 = $lines[178];
Re: Html page to array
JB4 wrote:$lines[178] or is that supposed to be 179?manixrock wrote:Code: Select all
$line179 = $lines[178];
In a 0-based array the 1st line would have index 0, 2nd line index 1, ..., 179th line index 178.
So you get the 179th line with $lines[178];
Re: Html page to array
ok, I figured either it was a typo, or you start on line 0.