Find files in PHP

There is a super easy way to get all files matching some particular pattern in PHP. In comes “glob”. It sounds like some slimey green goop but really it is quite handy. Glob will return an array of files that match a pattern. Handy huh?

  1. $files = glob("*.txt");
  2. foreach ($files as $filename) {
  3.     echo "$filename size " . filesize($filename) . "\n";
  4. }
  5.  

Videos, Slideshows and Podcasts by Cincopa Wordpress Plugin