Highlight Lines from a file

Greetings all,

Looking for some help with highlighting text from a file. Here’s the scenario:

I have a PHP site with buttons that run scripts and generate output files. (Reports). The output for one such script would be displayed on the page as such:


– Patching Compliance Report Threshold = 2013-11-26

Severity----ID-----------Hostname—Status-----------------------------------------------------------

Warning! - 1000011002 - stuxsh01 - No history of scheduled patches!

Warning! - 1000011003 - stuxsh04 - No history of scheduled patches!

This text comes from a plain text file called events.txt which is displayed when the script has finished it’s run. I would like to highlight entire lines (or just keywords if that’s not possible), so that any line that has a Warning! will be highlighted in Yellow.

just read the file line by line and check if the line contain “warning”

ex:[php]
.highlight { background-color: yellow }

<?php $handle = fopen("data.txt", "r"); if ($handle) { while (!feof($handle)) { $line = fgets($handle, 4096); ?>
<span class="<?= (strpos(strtolower($line), 'warning') !== false) ? 'highlight' : '' ?>"><?= $line ?></span><br />
<?php

}
fclose($handle); // Close the file.
}[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service