我正在制作一个 php 文件以在引入名称的目录中搜索图像,但函数 preg_match 向我返回此错误:“警告:preg_match():分隔符不得为字母数字或反斜杠”。代码是这样的:
<?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>";
}
}
}
?>
它给了我循环中每次迭代的警告。我ve trying to fix it but I can
吨。有人可以帮我吗?