title: Breaking an array and create new array in php
body: <p>I have the following array <code>$data</code></p>
  
  <pre><code> Array
  (
      [0] =&gt; Array
          (
              [sku] =&gt; 049-1090
              [color] =&gt; Beige,Brown
              [Finish] =&gt; Distressed,Handscraped,Matt
              [Grade] =&gt; B (Select/Advantage)
              [Installation Location] =&gt; Second Floor,Main Floor
              [Installation Method] =&gt; Nail Down
              [Specie] =&gt; Maple
              [Warranty] =&gt; 25 Years
              [Width] =&gt; 5 inch
          )
  
      [1] =&gt; Array
          (
              [sku] =&gt; 107-1079
              [color] =&gt; Brown,Yellow
              [Edge] =&gt; Square Edge
              [Finish] =&gt; Matt
              [Grade] =&gt; B (Select/Advantage)
              [Installation Location] =&gt; Second Floor,Main Floor
              [Installation Method] =&gt; Glue Down,Nail Down
              [Specie] =&gt; Maple
              [Warranty] =&gt; 25 Years
              [Width] =&gt; 3 5/8 inch
          )
      )
  </code></pre>
  
  <p>Now I want to create an array <code>$final_array</code> which will contain only 2 keys. First key is <code>sku</code> and second key is <code>feature</code>. <code>feature</code> key will consist of the values of all of the keys other than <code>sku</code> exploding the values at <code>,</code> so the final array will look like: </p>
  
  <pre><code>    (
      [sku]=&gt;049-1090
      [feature]=&gt;color:Beige
  )
   (
      [sku]=&gt;049-1090
      [feature]=&gt;color:Brown
  )
  (
      [sku]=&gt;049-1090
      [feature]=&gt;Finish:Distressed
  )
  (
      [sku]=&gt;049-1090
      [feature]=&gt;Finish:Handscraped
  )
  (
      [sku]=&gt;049-1090
      [feature]=&gt;Finish:Matt
  )
  </code></pre>
  
  <p>And so on for the second <code>sku</code></p>
  
  <p>I have tried like this:</p>
  
  <pre><code>$final_array = array();
  foreach($data as $value){
  
     foreach($value as $innerkey=&gt;$innervalue){
  
              $final_array[] = ['sku'=&gt;$innerkey,'feature'=&gt;$innervalue];
  
     }
  
  }
  
  
  echo "&lt;pre&gt;";
  print_r($final_array);
  echo "&lt;/pre&gt;";
  </code></pre>