×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: userc865b
Added: Sep 27, 2017 10:32 AM
Modified: Nov 16, 2017 9:25 PM
Views: 14
Tags: php
  1. <?$dir = new DirectoryIterator($_SERVER['DOCUMENT_ROOT']."/folder1/folder2");
  2. foreach ($dir as $fileinfo) {
  3.     if (!$fileinfo->isDot()) {
  4.         if ($fileinfo->isFile())
  5.          var_dump($fileinfo->getFilename());
  6.          //   echo $fileinfo->getExtension(); ->suffix
  7.     }
  8. }
  9.  
  10. // read file
  11.  
  12. $handle = @fopen("/tmp/inputfile.txt", "r");
  13. if ($handle) {
  14.     while (($buffer = fgets($handle, 4096)) !== false) {
  15.         echo $buffer;
  16.     }
  17.     fclose($handle);
  18. }