Get an array of filenames or directories matching a specified pattern in PHP

Description

The following code shows how to get an array of filenames or directories matching a specified pattern.

Example


//w  ww  . j a v  a 2  s.  c o m
<?php
    print_r(glob("*.txt"));
    print_r(glob("*.bat"));
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    File »




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