foreach (glob("$path/*.jpg") as $filename) {
echo "$filename";
}

dove $path è la sottodirecoty corrente