title: Explode and transpose nominated comma-separated strings of an associative array
body: <p>I have an array with comma-separated values like below:</p>
  <pre><code>array:5 [
    &quot;manufacturer&quot; =&gt; &quot;BB&quot;
    &quot;width&quot; =&gt; &quot;245,225, ...&quot;
    &quot;height&quot; =&gt; &quot;45,65, ...&quot;
    &quot;diameter&quot; =&gt; &quot;19,17, ...&quot;
    &quot;type&quot; =&gt; &quot;AA&quot;
  ]
  </code></pre>
  <p>There is no limit to how many comma-separated values there may be, but all 3 of them will have same length.</p>
  <p>From this, I want to get transposed output like below:</p>
  <pre><code>[
      245,
      45,
      19,
  ],
  [
      45,
      65,
      17
  ]
  </code></pre>
  <p>So far, I have tried following code.</p>
  <pre><code>$mandatoryFields = [
      'width',
      'height',
      'diameter',
  ];
  
  $finalArray = [];
  for ($i = 0; $i &lt; 2; $i+=1) {
      foreach ($mandatoryFields as $mandatoryField) {
          $fieldArray = explode(',', $executionArray[$mandatoryField]);
          $finalArray[] = [
              $fieldArray[$i]
          ];
      }
  }
  dd($finalArray);
  </code></pre>
  <p>But it is returning me:</p>
  <pre><code>array:6 [
    0 =&gt; array:1 [
      0 =&gt; &quot;245&quot;
    ]
    1 =&gt; array:1 [
      0 =&gt; &quot;45&quot;
    ]
    2 =&gt; array:1 [
      0 =&gt; &quot;19&quot;
    ]
    3 =&gt; array:1 [
      0 =&gt; &quot;225&quot;
    ]
    4 =&gt; array:1 [
      0 =&gt; &quot;65&quot;
    ]
    5 =&gt; array:1 [
      0 =&gt; &quot;17&quot;
    ]
  ]
  </code></pre>