I`m making a php file to search images in a directory introducing the name, but the function preg_match returns me this error: "Warning: preg_match(): Delimiter must not be alphanumeric or backslash". The code is this:
<?php
$ruta='fotos';
// Usamos dir
$dir=dir($ruta);
// Archivo a Buscar
$busqueda=$_POST['busqueda'] ;
$buscar = $busqueda;
// Recorremos los Archivos del Directorio
while ($elemento = $dir->read())
{
// Evitamos el . y ...
if ( ($elemento != '.') and ($elemento != '..'))
{
// Vemos si Existe el Archivo
if (preg_match($buscar, $elemento) AND is_file($ruta.$elemento) )
{
echo " Archivo : $elemento <br>";
}
}
}
?>
It gives me the warning for each iteration in the loop. Ive trying to fix it but I can
t. Can anybody help me, please?