help for php regular expression?

ALVIN

New member
here is my code and my reg ex:

<?php
$f = fopen ("LowLevelLogs.txt", "r");
$ln= 0;
while ($line= fgets ($f)) {
++$ln;
//printf ("%2d: ", $ln);
if ($line===FALSE) {
echo ("FALSE\n");
}
else {
if (preg_match("/TEST/", $line, $matches)) {
echo $matches[0]."<br>";
}
}
}
fclose ($f);
?>

the problem is that i want to print the whole line that matches the reg ex.
Here is the text file:

12-31-1969-04:00:00:PMTEST=================
12-31-1969-04:00:00:PMTESTSTART OF VPN TEST
12-31-1969-04:00:00:PMTEST=================
12-31-1969-04:00:00:PMTESTConfiguring MPLS Core Devices
12-31-1969-04:00:00:PMTESTConnect to 172.24.1.61
12-31-1969-04:00:00:PMTESTConfiguring MPLS Protocol
12-31-1969-04:00:00:PMINFOset protocols mpls interface ge-3/2/0
12-31-1969-04:00:00:PMINFOset protocols mpls interface ge-3/3/0
12-31-1969-04:00:00:PMINFOset protocols mpls interface lo0
12-31-1969-04:00:00:PMTESTConfiguring Interfaces
12-31-1969-04:00:00:PMTESTConfiguring Interface ge-3/2/0
12-31-1969-04:00:00:PMINFOset interfaces ge-3/2/0 enable
12-31-1969-04:00:00:PMINFOset interfaces ge-3/2/0 unit 0
12-31-1969-04:00:00:PMINFOset interfaces ge-3/2/0 unit 0 family mpls
12-31-1969-04:00:00:PMINFOset interfaces ge-3/2/0 unit 0 family inet address 10.1.1.1/30
12-31-1969-04:00:00:PMTESTConfiguring Interface ge-3/3/0
is it possible to store each line into <div>?
 
Back
Top