Any idea how to get my files using only file extension? Eg. (.cfg)
I tried foreach (glob("*.cfg") as $filename) but i need to know the path in order to use glob method.
Any idea how to get my files using only file extension? Eg. (.cfg)
I tried foreach (glob("*.cfg") as $filename) but i need to know the path in order to use glob method.
 
    
    As mentioned by @bansi, you should
The example given there should work for you:
$basepath        = "root/directory/for/search";
$start_directory = new RecursiveDirectoryIterator($basepath);
$iterator        = new RecursiveIteratorIterator($iterator);
$result          = new RegexIterator($iterator, '/^.+\.cfg$/i', RecursiveRegexIterator::GET_MATCH);
After you got your results, you can access your file paths in a list just as you entered it via $basepath:
foreach( iterator_to_array($result) as $file)
{
    echo "config found at: $file[0]";
}
You might find this post useful as well.
A little more background can be found in this article.