I am learning to program in this language and I have a problem, I can not extract the line that contains a particular phrase.
I leave the code in case you can help me or guide me a little, since it only prints false and never finds the searched text
<?php
$ruta = "\\x-wing\logs\"; //ruta actual
echo listarArchivos($ruta);
function listarArchivos( $path ){
$dir = opendir($path);
$files = array();
while ($elemento = readdir($dir)){
if( $elemento != "." && $elemento != ".."){
if(is_dir($path.$elemento)){
listarArchivos( $path.$elemento.'/' );
}
else
{
$files[] = $elemento;
}
}
}
echo $path."<br>";
for($x=0; $x<count( $files ); $x++){
$fila = $path.$files[$x];
echo $files[$x]."<br> ";
$fp = fopen($fila,"r");
while(!feof($fp)) {
$linea = fgets($fp);
if(stristr($linea, "Respaldo terminado") == TRUE){
echo $linea. "<br>";
} else {
echo 'Falso';
}
}
fclose($fp);
}
echo "<BR>";
}
?>