I am writing a code that consists of reading files from a folder in which there are images and links, and I need to differentiate between image and link, but I have been very very caught. The code is this in case you can help me:
//Leer archivos de la carpeta
$filehandle = opendir($ruta); // Abrir archivos de la carpeta
//Bucle para seleccionar filas y columnas
for($i=0; $i<$numFilas; $i++){
$Visualizacion .= "<tr>";
for($w=0; $w<$numColumnas; $w++){
$Visualizacion .= "<td>";
while($file = readdir($filehandle)){
if($file != "." && $file != ".."){
$tamanyo = GetImageSize($ruta . $file);
$rutaFile = "$ruta$file";
$Visualizacion .= "<td><a TARGET = '_top' href = '$ruta$file'><img src='$ruta$file' $tamanyo[3]></a></td>";
$patron = "/I_(.*)_IH_(.*)_HP_(.*)_PN_(.*)_N\./";
$result = preg_match($patron, $file, $resultados);
$nombreCompleto = $resultados[0];
$vecesMostrar = $resultados[1];
$horariosProhibidos = $resultados[2];
$periodo = $resultados[3];
$nombre = $resultados[4];
$rutaCompleta = "$ruta$file";
//Llamo a la función que se encarga de agregar los registros
agregarImpresiones($nombre,$ruta, $vecesMostrar, $horariosProhibidos, $periodo);
impresionesTotales($nombre, $ruta, $periodo, $vecesMostrar, $rutaCompleta);
break;
}//end if
}//end while
$Visualizacion .= "</td>";
}//end for
$Visualizacion .= "</tr>";
}//end for
closedir($filehandle); // Fin lectura archivos
With the filehandle I understand that it reads all the files, but how does it differentiate them? Thank you very much for the help!