Searching Files in directory

Searching Files in directory

Following code print all the file names in the files directory

$directory = 'files';
$files = glob("$directory/{*.*}",GLOB_BRACE);

print_r($files);

In the following line
$files = glob(”$directory/{*.*}”,GLOB_BRACE);

if we specify {*.txt} instead of {*.*}, then glob will return
only the txt files, and also we can specify the multiple file formats like {*.txt,*.doc}

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.