There is a src folder with php scripts and a google folder. In the Google folder are php scripts and many more subfolders with PHP scripts. How to use the foreach and glob functions to go through all subfolders and connect all php files?

    1 answer 1

    It is possible, but hardly necessary ... usually.
    And you can get around recursion, my friend:

    <? function incl($path){ foreach(glob($path . DIRECTORY_SEPARATOR . '*') as $val){ if(is_dir($val)) incl($val); else if(preg_match('/\.(?:php|phtml|phps)$/', $val)){ // Тут делать что-то с PHP-файлом, например require_once $val } } } incl(__DIR__ . DIRECTORY_SEPARATOR . 'src');