How to show folders if they contain specific file in php?

<?php
    $dirs = glob("folder/files/*", GLOB_ONLYDIR);
    foreach($dirs as $val){
        echo '<option value="'.$val.'">'.$val."</option>\n";
    }
?>

Can I make this php code find(scan) and show folders where there is specific file (smth.txt for example) ?