title: PhP multidimensional array to individual array
body: <p>I have a multidimensional array which I want to convert to individual arrays.</p>
  <p>Original array is</p>
  <pre><code>$hos_pabsl = array(
      0 =&gt;
      array(
          'tile_id' =&gt; '1',
          'tile_type' =&gt; '4',
          'title' =&gt; 'Introduction',
          'topicNum' =&gt; '1',
          'topicTitle' =&gt; 'Introduction',
          'subNum' =&gt; NULL,
      ),
      1 =&gt;
      array(
          'tile_id' =&gt; '2',
          'tile_type' =&gt; '9',
          'title' =&gt; 'Beer',
          'topicNum' =&gt; '2',
          'topicTitle' =&gt; 'Beer',
          'subNum' =&gt; NULL,
      ),
      2 =&gt;
      array(
          'tile_id' =&gt; '3',
          'tile_type' =&gt; '4',
          'title' =&gt; 'Methods of Brewing',
          'topicNum' =&gt; '2',
          'topicTitle' =&gt; 'Beer',
          'subNum' =&gt; NULL,
      ),
      3 =&gt;
      array(
          'tile_id' =&gt; '4',
          'tile_type' =&gt; '11',
          'title' =&gt; 'Beer Styles',
          'topicNum' =&gt; '2',
          'topicTitle' =&gt; 'Beer',
          'subNum' =&gt; '',
      ),
  );
  </code></pre>
  <p>I want to convert this array into individual arrays named <code>'tile_id' , 'tile_type' , ...</code>.</p>
  <p>Currently I am doing it the following way !</p>
  <pre><code>$tile_id = [];
  $tile_type = [];
  $title = [];
  $topicNum = [];
  $topicTitle= [];
  $subNum = [];
  
  foreach($hos_pabsl as $val){
      array_push($tile_id, $val['tile_id']);
      array_push($tile_type, $val['tile_type']);
      array_push($title, $val['title']);
      array_push($topicNum, $val['topicNum']);
      array_push($topicTitle, $val['topicTitle']);
      array_push($subNum, $val['subNum']);
  }
  </code></pre>
  <p><strong>Problem 1:</strong> IS this the most efficient way (in terms of speed) to do this operation?</p>
  <p><strong>Problem 2:</strong> <br>
  The <code>$hos_pabsl</code> array's index (or keys) are always going to be sequential. However, my problem is that for second array (at level 2 OR $hos_pabsl[0]) the index (or keys) might increase or decrease. <br>
  E.g. all arrays in might have only 2 items 'tile_id'  &amp; 'title'. OR might have one extra item 'description'. So how can I make the above operation dynamic ? <br><br>
  To Solve problem 2, I have thought of using array_keys to extract names first  <code> $names = array_keys($hos_pabsl[0])</code> then using those names as array names like <code> ${$names[0]} =[]</code>. Again I don't think this is the right/efficient way to do this.</p>
  <br>
  <br>
  <p>Any guidance on this would be really appreciated.</p>