Home > Backend Development > PHP Tutorial > PHP traverses the files in the folder and obtains the value of the input name

PHP traverses the files in the folder and obtains the value of the input name

WBOY
Release: 2016-07-29 09:09:41
Original
918 people have browsed it

$dir = dirname(__FILE__); //The name of the directory to be traversed ->The folder where the current file is located
//$dir='D:PHPwampwwwadminhostsadmin';
//PHP traverses the folder Download all files
$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 into a one-dimensional array
  }
  }
}
//print_r($arr);
closedir( $handle);
//PHP gets the value of input->name
foreach ($_POST AS $key=>$value){
 if(!in_array($key,$arr)){ //Judge the name value Is it in $arr? echo "$key: does not exist";
}
}
?>




test


 


  
  


  

  


  


  


  < input type="hidden" name="text">


  


 





The above introduces PHP to traverse the files in the folder and obtain the value of the input name, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
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 Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template