Ok, I am using fgets and fopen for a webpage. I am trying to basically pull some info from a given URL but the data is in a table. Right now I am keeping this basic.
So the table on this webpage is setup like this:
| Score |
|---------|
| 45431|
|---------|
And I just want to pull score. The way I am doing it is by preg_match and finding Score and then reading the NEXT line and stripping it of tags and what have you, since this is the only data cell on that line....here is the code:
//The URL
$filename = "http://somewebsite.com/test.html";
$fp = fopen($filename, "r") or die ("Couldn't open $filename");
while(!feof($fp)) {
$line = fgets($fp, 1024);
//find the word Score
if(preg_match('|Score|i', $line)) {
//We do not need the line "Score" but the next line that
//actually has the number (score) we want to pull. This is
//where the issue resides. $fp++ ????
$line = fgets($fp++, 1024);
echo "Score: " . trim(strip_tags($line)) . "<br>\n";
}
}
I am just having issues getting the code to read the next line...well...it reads it fine, but the output becomes this:
Score: 45431
Score:
I have a feeling I am doing something wrong with $fp++ and its looping twice.