Array is displaying inside another array when it shouldn't
<p>I created a function that should in theory create an array from another array (basically what i want to do its bring it down 1 level).</p>

<p>My problem is that somehow the code creates another array inside the new array when it shouldn't.... and even more the output is rather strange.
The final array should all be in the same level but somehow it creates it multidimensional and with extra values.</p>

<p>The problem seems to be in the loop, but i can't see where</p>

<p>any help is appreciated.</p>

<pre><code>    public function pullCompetencyByCID ( $cID ) {
                    $sql = 'SELECT * FROM ldc_competency_'.$this-&gt;lang.' WHERE cID='.$cID;
                    $result = $this-&gt;db-&gt;query($sql)-&gt;fetchAll(PDO::FETCH_ASSOC);                   
                         foreach ( $result as $key2 =&gt; $val2 ){
                                switch ($key2){
                                    case 'cName':       $cName = $val2;         
                                                        break;
                                    case 'cID':         $cID = $val2;
                                                        break;
                                    case 'cLevel':      $cLevel = $val2;
                                                        break;
                                    case 'cDetails':    $cDetails = $val2;
                                                        break;
                                    case 'cSummary':    $cSummary = $val2;
                                                        break;
                                }
                        }
                    $pullCompetency = array('cName'=&gt;$cName,'cID'=&gt;$cID, 'cLevel'=&gt;$cLevel, 'cDetails'=&gt;$cDetails, 'cSummary'=&gt;$cSummary);          

                    return $pullCompetency;
    }
</code></pre>

<p>The output of that code is </p>

<pre><code> Array ( 
    [cName] =&gt; Array ( 
                        [cID] =&gt; 2 
                        [cName] =&gt; dos
                        [cLevel] =&gt; 2
                        [cDetails] =&gt; doss
                        [cSummary] =&gt; dosssss 
                         ) 
    [cID] =&gt; 2
    [cLevel] =&gt; 
    [cDetails] =&gt; 
    [cSummary] =&gt; 
)
</code></pre>

<p>The output of just the <code>$result</code> is</p>

<pre><code>Array ( 
    [0] =&gt; Array ( 
                    cID] =&gt; 2 
                    [cName] =&gt; dos 
                    [cLevel] =&gt; 2 
                    [cDetails] =&gt; doss 
                    [cSummary] =&gt; dosssss
                     )
     )
</code></pre>

<p>to avoid confusion the desired result should be</p>

<pre><code> Array ( 
        [cID] =&gt; 2 
        [cName] =&gt; dos 
        [cLevel] =&gt; 2 
        [cDetails] =&gt; doss 
        [cSummary] =&gt; dosssss
         )
</code></pre>
