create a new class object on the fly using a foreach loop and the DirectoryIterator functions
<p>I have a class that parses XML documents into an array.</p>

<p>I have 2 XML documents I want to parse and want to create a new class object on the fly using a foreach loop and the DirectoryIterator functions.</p>

<p>so far this is my attemp:</p>

<pre><code>$settingsIterator = new DirectoryIterator(SETTINGS_PATH);

foreach ($settingsIterator as $fileInfo) {

    if ($fileInfo-&gt;isFile()) {

        $xmlFileObjName = strtolower(str_replace(".xml", "", $fileInfo-&gt;getFilename()));
        ${$xmlFileObjName} = new XML();
        ${$xmlFileObjName}-&gt;loadXML(SETTINGS_PATH . $fileInfo-&gt;getFilename());
    }
}
</code></pre>

<p>but of course this won't work. Is there a method to accomplish something like this?</p>

<p>My end goal is to have my script on execution iterate through my settings folder and create new XML object from each xml file in the directory.</p>
