Home  >  Article  >  Backend Development  >  PHP遍历文件夹下的文件跟获取到input name的值

PHP遍历文件夹下的文件跟获取到input name的值

WBOY
WBOYOriginal
2016-06-13 12:28:00890browse

PHP遍历文件夹下的文件和获取到input name的值

$dir = dirname(__FILE__); //要遍历的目录名字 ->当前文件所在的文件夹
//$dir='D:\PHP\wamp\www\admin\hosts\admin'; 
//PHP遍历文件夹下所有文件 
$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); //把$file转换成数组
      $arr[]=$files['0'];//转换成一维数组
    }
  } 

//print_r($arr);
closedir($handle); 
//PHP获取input->name的值
foreach ($_POST AS $key=>$value){
  if(!in_array($key,$arr)){ //判断name值在不在$arr里面
    echo "$key:不存在";
}

}
?>




test


  

    
    


    


    


    


    


    


    


  




 

 
 
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:lajp 实现php高效率调用javaNext article:phpredis 装配