Home > php教程 > php手册 > PHP遍历文件夹下的文件和获取到input name的值,

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

WBOY
Release: 2016-06-13 08:49:26
Original
1090 people have browsed it

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


  

    
    


    


    


    


    


    


    


  




 

   
source:php.cn
Statement of this Website
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
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template