Reading part of a page....

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Tubby
Forum Commoner
Posts: 28
Joined: Thu Oct 17, 2002 5:55 pm

Reading part of a page....

Post by Tubby »

I'm using this to gather info from a page:

Code: Select all

<?php
$page = fopen("pageinfo.php", "r");
$html = fread($page, 800); //number of characters to get
fclose($page);
echo "$html";
?>
But I want to tell it not to get the info from the top of the page, but from a certain line of code onwards...
line of code where the info starts:

Code: Select all

<table width=468 cellpadding=0 cellspacing=0 border=0>
however, I can't edit the source page because it isn't mine (but using it with their permission) and the line of code I want it to start reading from isn't always on the same line number, because above it is a live news feed which varies in length every hour.
Is this possible, if so could someone tell me how :D

thanks.
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

well, if <table> tag is the only one in that file then you can search for it and then get the character number, then load from there........did u get that? :roll:
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

Code: Select all

...
fclose($page);
$output = strstr($html,'&lt;table width=468 cellpadding=0 cellspacing=0 border=0&gt;');
echo $output; // no need for quotes
http://www.php.net/manual/en/function.strstr.php
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

lol..that's what i said!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

take a look at the post times ;)
User avatar
Tubby
Forum Commoner
Posts: 28
Joined: Thu Oct 17, 2002 5:55 pm

Post by Tubby »

About 5 mins after posting that message I found what I wanted in the php manual :oops:

Thanks anyway :D
qads
DevNet Resident
Posts: 1199
Joined: Tue Apr 23, 2002 10:02 am
Location: Brisbane

Post by qads »

hmm....i wish i could slap you..lol..just jokein :P
User avatar
Tubby
Forum Commoner
Posts: 28
Joined: Thu Oct 17, 2002 5:55 pm

Post by Tubby »

hehehe :D
I'd been looking all morning and couldnt find what I wanted. Asked here, then looked again in the same place and found it, always happens like that :lol:
Post Reply