php -- combining arrays
<p>So I'm trying to write a function that does the following: I have about 20 or so XML files (someday I will have over a hundred) and in the header of each file is the name of a person who was a peer review editor <code>&lt;editor role="PeerReviewEditor"&gt;John Doe&lt;/editor&gt;</code>. I want to run through the directory where these files are stored and capture the name of the Peer-Review-Editor for that file. I want to end up with an variable <code>$reviewEditorNames</code> that contains all of the different names. (I will then use this to display a list of editors, etc.)</p>

<p>Here's what I've got so far. I'm worried about the last part. I feel like the attempt to turn <code>$editorReviewName</code> into <code>$editorReviewNames</code> is not going to combine the individuals for each file, but an array found within a given file (even if there is only one name in a given file, and thus it is an array of 1) </p>

<p>I'm grateful for your help.</p>

<pre><code>function editorlist()
{
    $filename = readDirectory('../editedtranscriptions');
    foreach($filename as $file)
    {
        $xmldoc = simplexml_load_file("../editedtranscriptions/$file");
        $xmldoc-&gt;registerXPathNamespace("tei", "http://www.tei-c.org/ns/1.0");
        $reviewEditorName = $xmldoc-&gt;xpath("//tei:editor[@role='PeerReviewEditor']");

        return $reviewEditorNames[] = $reviewEditorName;
    }


}
</code></pre>
