Forum Moderators: coopster
echo("<p class = 'text'>Path: $path<br><br>File Name Search Text: ".getFileName($fileNameSearch)."<br>Number of files matching criteria: ".count($arrFiles)."
<br>File Name(s):</p>");
foreach($arrFiles as $key => $i){
if(($key % 2) == 1){
$div = "output3";
}//if $key
else{
$div = "output2";
}//else
echo("<br><br><br><div id = '{$div}'><p class = 'text'>File Name: ".getFileName($i)."</p>");
$lines = file($i);
foreach($lines as $j){
echo("<p class = 'text'>$j</p>\n");
}//foreach
echo("</div>");
}//$foreach
}//$contentOutput
This function takes in an array of files the path they are in and the search text. It then echos a div and stores the contents of a file into an array. Then it prints out every line of that array. Now my problem is in the line echo("<p class = 'text'>$j</p>\n"); because $j is the contents of a file and if it's contents are PHP itself it will error (for obvious reasons). What I am wondering is if there is any way to echo it without parsing anything without writing a function that searches each line for anything that would screw up php (i.e. a ?> or <?php) and then escaping it? Thanks