Ok, two options. Both will create the var $lines which will contain an array of matched lines. I like the second better.. Also, I'm not all that great at regex so maybe someone else will have a better one for you but this worked for me.
<?php
$file = 'C:/path/to/file.htm';
if (($fp = fopen($file, 'r')) !== false) {
$lines = array();
while (!feof($fp)) {
$line = fgets($fp);
if (preg_match("/(\<TD\s*align\=\"right\"\>(.*?)\<\/TD\>\<TD\>(.*?)\<\/TD\>\<TD\s*align\=\"right\"\s*class\=\"highlight\"\>(.*?)\<\/TD\>)/i", $line)) {
$lines[] = $line;
}
}
} else {
trigger_error("Could not read the file. [$file]", E_USER_WARNING);
}
//////// OR /////////
$file = 'C:/path/to/file.htm';
if (($contents = file_get_contents($file)) !== false) {
$lines = array();
if (preg_match_all("/(\<TD\s*align\=\"right\"\>(.*?)\<\/TD\>\<TD\>(.*?)\<\/TD\>\<TD\s*align\=\"right\"\s*class\=\"highlight\"\>(.*?)\<\/TD\>)/i", $file, $matches)) {
$lines = $matches[1];
}
} else {
trigger_error("Could not read the file. [$file]", E_USER_WARNING);
}
// Here's an example of what you should get from the regex.
// Just run this and you'll see what the output would be.
$file = '<TD align="right">Text</TD><TD> More Text</TD><TD align="right" class="highlight">Even More Text</TD>' . "\r\n" .
'<TD align="right">Text2</TD><TD> More And More Text</TD><TD align="right" class="highlight">Even More More Text</TD>';
if (preg_match_all("/(\<TD\s*align\=\"right\"\>(.*?)\<\/TD\>\<TD\>(.*?)\<\/TD\>\<TD\s*align\=\"right\"\s*class\=\"highlight\"\>(.*?)\<\/TD\>)/i", $file, $matches)) {
print_r($matches[1]);
}
?>