title: Associative index array to associative associative array
body: <p><strong>Problem</strong></p>
  
  <p>I have an array which is returned from PHPExcel via the following</p>
  
  <pre><code>&lt;?php
      require_once 'PHPExcel/Classes/PHPExcel/IOFactory.php';
      $excelFile = "excel/1240.xlsx";
      $objReader = PHPExcel_IOFactory::createReader('Excel2007');
      $objPHPExcel = $objReader-&gt;load($excelFile);
      foreach ($objPHPExcel-&gt;getWorksheetIterator() as $worksheet) {
      $arrayData[$worksheet-&gt;getTitle()] = $worksheet-&gt;toArray();
      }           
      print_r($arrayData);
  ?&gt;
  </code></pre>
  
  <p>This returns:</p>
  
  <pre><code> Array
      (
          [Films] =&gt; Array
              (
                  [0] =&gt; Array
                      (
                          [0] =&gt; Name
                          [1] =&gt; Rating
                      )    
                  [1] =&gt; Array
                      (
                          [0] =&gt; Shawshank Redemption
                          [1] =&gt; 39
                      )    
                  [2] =&gt; Array
                      (
                          [0] =&gt; A Clockwork Orange
                          [1] =&gt; 39
                      )    
              )      
  
      [Games] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [0] =&gt; Name
                      [1] =&gt; Rating
                  )    
              [1] =&gt; Array
                  (
                      [0] =&gt; F.E.A.R
                      [1] =&gt; 4
                  )    
              [2] =&gt; Array
                  (
                      [0] =&gt; World of Warcraft
                      [1] =&gt; 6
                  )    
          )    
  )
  </code></pre>
  
  <p>What I would like to have is</p>
  
  <pre><code>Array
  (
      [Films] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [Name] =&gt; Shawshank Redemption
                      [Rating] =&gt; 39
                  )
              [1] =&gt; Array
                  (
                      [Name] =&gt; A Clockwork Orange
                      [Rating] =&gt; 39
                  )
          )
  
      [Games] =&gt; Array
          (
              [0] =&gt; Array
                  (
                      [Name] =&gt; F.E.A.R
                      [Rating] =&gt; 4
                  )
              [1] =&gt; Array
                  (
                      [Name] =&gt; World of Warcraft
                      [Rating] =&gt; 6
                  )
          )
  )
  </code></pre>
  
  <p>The arrays names (Films, Games) are taken from the sheet name so the amount can be variable.  The first sub-array will always contain the key names e.g. Films[0] and Games[0] and the amount of these can be varible.  I (think I) know I will need to do something like below but I'm at a loss.</p>
  
  <pre><code>foreach ($arrayData as $value) {
      foreach ($value as $rowKey =&gt; $rowValue) {
          for ($i=0; $i &lt;count($value) ; $i++) { 
              # code to add NAME[n] as keys
          }
      }
  }
  </code></pre>
  
  <p>I have searched extensively here and else where if it is a duplicate I will remove it.</p>
  
  <p>Thanks for any input</p>