0 && $splits[0] === 'BarcodeBakery') { if ($c > 1) { if ($splits[1] === 'Common') { $tryFolders = array('barcode-common', 'gs1ai'); } else { // Try all the other folders $tryFolders = array_filter(scandir($packageFolder), function ($f) { if ($f !== '.' && $f !== '..' && $f !== 'barcode-common' && $f !== 'gs1ai') { return true; } return false; }); } } } if (count($tryFolders) > 0) { $file = implode('/', array_slice($splits, 2)) . '.php'; foreach ($tryFolders as $folder) { $fullpath = $packageFolder . '/' . $folder . '/src/' . $file; if (file_exists($fullpath)) { include $fullpath; break; } } } });