Could someone give me some pointers on pulling a table out of an existing page. I am able to read the source into an array and display it as the body of a page such as:
$counter=0;
$content = array();
$lines = file('filepath');
foreach ($lines as $line_num => $line) {
$contents[$line_num] = "$line";
} else {
echo "Page Not Available";
}
foreach ($contents as $value) {
$counter++;
print htmlspecialchars($contents[$counter]) . "<br />\n";
}
However, I am trying to retrieve table information from that page source. The information around the table may change so I need to find the instance of <table name="custinfo"> and take everything from there down to </table>. Can anyone suggest a way to find that tag in a page and copy all information between those tags to a separate file or store it in a different variable?
I tried using an If statement and printing the results to the page but it simply placed <table name="custinfo"> for each line in the file itself (ie. if there were 100 lines in the HTML file as a whole, but only 20 in the table, it would show the table tag 1000 times).
Any help on this would be great. Thanks in advance.