Check if a file folder contains certain extensions

Hello. I was wondering if anyone can help me with the following programming concern.

Using php. Does anyone know how to scan a folder located on a server; Seeing if the folder contains files of a specific file type. Namely, If I wanted to search for all the files in a folder with a *.jpg extension. USING IF / ELSE structure. IF the file(s) are found echo" JPG files exist" ELSE echo"No files containing such extensions exist."

Thanking you

Sounds like a homework assignment, but the interested operations you want to use are opendir, readdir, and then check the name of the file returned by readdir to see if the extension you are looking for exists.

Once you have some code written, post back if you need more help.

http://us3.php.net/manual/en/function.glob.php

Not a homework question. Far from it. But will keep you posted. Thanks.

Using a combination of scandir(), substr(), and a foreach loop can get it done pretty quickly and easily.