Create The Internet… It's What I Do EVERY Day – Joseph Yancey

16May/10N/A0

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.  
blog comments powered by Disqus

Buy Me a Beer

Well not really a beer
More like a Dr Pepper...