?php $dir = dirname(__FILE__); //The name of the directory to be traversed - the folder where the current file is located //$dir='D:PHPwampwwwadminhostsadmin'; //PHP traverses all files in the folder $handle= opendir($dir."."); $arr = array(); while($file=readdir($handle)){ if(is_file($file)){ if (
$dir = dirname(__FILE__); //The name of the directory to be traversed ->The folder where the current file is located
//$dir='D:PHPwampwwwadminhostsadmin';
//PHP traverses all files in the folder
$handle=opendir($dir.".");
$arr = array();
while($file=readdir($handle)) {
if(is_file($file)){
if ($file != "."&& $file != "..") {
$file = mb_substr($file,0,strripos ($file,'.'));
$files = explode(' ',$file); //Convert $file into an array
$arr[]=$files['0'];/ /Convert to one-dimensional array
}
}
}
//PRint_r($arr);
closedir($handle);
//PHP gets input->name value
foreach ($_POST AS $key=>$value){
if(!in_array($key,$arr)){ //Judge whether the name value is in $arr
echo "$ key: does not exist";
}
}
?>
< head>