php path failures and multidimensional array variable issues
===

I'm in the process of learning php and I set myself the goal of writing a very basic modular mvc framework in order to A: hone my skills, and B: come to a thorough understanding the complexities of such a framework.  I have been having a world of misery keeping execution paths straight working through class instantiation failures.  Now I am having serious trouble accessing arrays across different directory structures.

Alas, it appears that I am in over my head(as usual).

Here is the underlying information on what I have, what works and what doesn't.

1) I have front controller "index.php" in my root directory.

2) I have a sub directory called "framework" that contains 2 more sub directories: "system" and "modules".

3) In the "framework" directory I have a class, "fw.php" that I call static methods from in "index.php" to scan and instantiate whatever classes are stored in the "system" directory.  When I handle my business correctly, that works.

4) I am hoping to drop folders into the "modules" directory and have my router fetch the accompanying controllers and configuration files.  In a module there will be yet another sub directory called "config" that will e scanned for config files.

5) I call from "index.php" and "fw.php" loads my Config class in the "system" directory and the Config class scans the "modules" directory and successfully returns the names of all modules (directories) it contains, but everything breaks down from there.  The "MOD" constant is set with a define in index.php.  Oh...and I use "for" loops instead of "foreach" because things seem to go wack about 60% of time when I use them for some reasons yet to be determined.

Like I said, it appears that I am now in over my head.  Several days of pain, Google, trial and error have left me no recourse but to turn here and throw myself to the mercy of the gods of php.  Please help.  Here is the code in my Config class that fails:

<pre><code>

public function load()
{

    $modules = scandir(MOD);
    $n = count($modules);
    for($i=0;$i<$n;$i++)
    {
    if($modules[$i]==='.'||$modules[$i]==='..'||strpos($modules[$i],'.'))
    { unset($modules[$i]); }
		
    }
    // It works up to here and I can return the names in $modules, but not through $this->_config.
    // I have to return $modules directly so I assume it's a big snafu in my array handling.

    $m = count($modules); 
    for($i=0;$i<$m;$i++)
    {
    $mod = $modules[$i];
    $this->_config[$mod] = array();
    $cfgfiles = scandir(MOD.DS.$mod.DS.'config');
    $num = count($cfgfiles);

        for($j=0;$j<$num;$j++)
            {
            include(MOD.DS.$mod.DS.'config'.DS.$cfgfiles[$i]);
            $modcfg = substr($cfgfiles[$j], 0, -4);
            $this->_config[$mod][$modcfg] = array();
            $this->_config[$mod][$modcfg] = $cfg;
            }	
    } 
    return $this->_config;
}

</pre></code>


Thank You,
Mark

