Find pathnames matching a pattern in PHP

Description

The following code shows how to find pathnames matching a pattern.

Example


/*from  w ww . j  av a2  s  .  co m*/
//Convenient way how glob() can replace opendir()
<?php
foreach (glob("*.txt") as $filename) {
    echo "$filename size " . filesize($filename) . "\n";
}
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    File »




Directory
DirectoryIterator
Drive
File
File Permission
File Read Save
FileSystemIterator
Path
Zip