To Filter filenames or direcories in a specified matching pattern

glob(string pattern,flags)

pattern->required, to specify the pattern search
flags->optional

Function returns an array of filenames or directories if it is matched in a specified pattern

otherwise it will returns an empty array.

example:

$temp_directory=glob(”*.*”);
The above function returns the array of all filenames placed inside the folder.

$temp_images=glob(images.”/”.”*.jpg*”);
print_r($temp_images);

The above function returns the array of all filenames who are all contains the extension as ‘jpg’ placed inside the image ‘folder.

Output like this;

Array ( [0] => images/webdesign.jpg
[1] => images/web_development.jpg )

Posted by Kalaivani S

Leave a Reply

You must be logged in to post a comment.