Hey now-
I'm trying to parse a bunch of HTML-formatted surf reports that a friend has given me, and place them into a MySQL database of surf reports.
I'm using fgetss() to strip all the HTML tags and eregi() to do the pattern matching, but somehow what I've got isn't working correctly.
This is as far as I've gotten so far:
global $filename, $aFile, $buffer, $date, $out;
function stripIt($filename) {
$aFile = @fopen($filename, "r");
if(!$aFile) {
echo "Unable to open file";
exit;
}
while(!feof($aFile)) {
$buffer = fgetss($aFile, 4096);
if($buffer=eregi("Date/Time",$buffer)){
$date = eregi("(Date/Time)(.*)(Location)",$buffer,$out);
# additional pattern matches would go here...
}
}
fclose($aFile);
}
I am thinking that I need to buffer all of the text generated by fgetss() into a variable, and then do my pattern matching on that, but if I echo $buffer outside of the while(!feof($aFile)) loop, it's empty...so I am confused.
Any help much appreciated!