Instead of running the `glob()` function twice, why not something like this:

    $files = glob ('apps/*/conf/cli.php');
    $commands = array ();
    if ($files) {
        foreach ($files as $file) {
            // etc.
        }
    }