title: how to remove specific key from multidimension array
body: <h2>This is what the result i need to come out with</h2>
  <pre><code>&quot;data&quot;: [
          {
          &quot;ticket_category_id&quot;: &quot;677&quot;,
          &quot;ticket_category_name&quot;: &quot; Testing 500&quot;,
          &quot;ticket_category_order&quot;: &quot;1&quot;,
          &quot;tickets&quot;: 
                  [
                  {
                  &quot;ticket_id&quot;: &quot;927&quot;,
                  &quot;ticket_title&quot;: &quot;EDI Project Template with attachments&quot;,
                  &quot;ticket_order&quot;: &quot;1&quot;,
                  &quot;due_date&quot;: &quot;0000-00-00 00:00:00&quot;,
                  &quot;created_date&quot;: &quot;2018-05-16 10:01:04&quot;,
                  &quot;edited_date&quot;: &quot;2018-05-17 02:56:38&quot;,
                  &quot;updated_date&quot;: &quot;2018-05-17 02:56:38&quot;,
                  &quot;is_complete&quot;: &quot;0&quot;,
                  &quot;total_comment&quot;: &quot;0&quot;,
                  &quot;total_attachment&quot;: &quot;10&quot;,
                  &quot;total_checklist_items&quot;: &quot;48&quot;,
                  &quot;total_completed_checklist_items&quot;: &quot;0&quot;,
                  &quot;label&quot;: [
                           {
                          &quot;ticket_label_name&quot;: &quot;&quot;,
                          &quot;ticket_color_code&quot;: &quot;#FF3B30&quot;
                      },
                      &quot;#D4891C&quot;: {
                          &quot;ticket_label_name&quot;: &quot;IN PROGRESS&quot;,
                          &quot;ticket_color_code&quot;: &quot;#D4891C&quot;
                      }]
                  },
                  &quot;people&quot;: []
              },
              {
                  &quot;ticket_id&quot;: &quot;928&quot;,
                  &quot;ticket_title&quot;: &quot;EDI Project Template&quot;,
                  &quot;ticket_order&quot;: &quot;2&quot;,
                  &quot;due_date&quot;: &quot;0000-00-00 00:00:00&quot;,
                  &quot;created_date&quot;: &quot;2018-05-16 10:01:04&quot;,
                  &quot;edited_date&quot;: &quot;0000-00-00 00:00:00&quot;,
                  &quot;updated_date&quot;: &quot;0000-00-00 00:00:00&quot;,
                  &quot;is_complete&quot;: &quot;0&quot;,
                  &quot;total_comment&quot;: &quot;0&quot;,
                  &quot;total_attachment&quot;: &quot;0&quot;,
                  &quot;total_checklist_items&quot;: &quot;48&quot;,
                  &quot;total_completed_checklist_items&quot;: &quot;0&quot;,
                  &quot;label&quot;: [
                           {
                          &quot;ticket_label_name&quot;: &quot;&quot;,
                          &quot;ticket_color_code&quot;: &quot;#4CD964&quot;
                      }]
                  },
                  &quot;people&quot;: []
              }
             ]
  </code></pre>
  <p>But what i get the result is like below</p>
  <pre><code> {
      &quot;data&quot;: [
          {
              &quot;ticket_category_id&quot;: &quot;677&quot;,
              &quot;ticket_category_name&quot;: &quot; Testing 500&quot;,
              &quot;ticket_category_order&quot;: &quot;1&quot;,
              &quot;tickets&quot;: {
                  &quot;927&quot;: {
                      &quot;ticket_id&quot;: &quot;927&quot;,
                      &quot;ticket_title&quot;: &quot;EDI Project Template with attachments&quot;,
                      &quot;ticket_order&quot;: &quot;1&quot;,
                      &quot;due_date&quot;: &quot;0000-00-00 00:00:00&quot;,
                      &quot;created_date&quot;: &quot;2018-05-16 10:01:04&quot;,
                      &quot;edited_date&quot;: &quot;2018-05-17 02:56:38&quot;,
                      &quot;updated_date&quot;: &quot;2018-05-17 02:56:38&quot;,
                      &quot;is_complete&quot;: &quot;0&quot;,
                      &quot;total_comment&quot;: &quot;0&quot;,
                      &quot;total_attachment&quot;: &quot;10&quot;,
                      &quot;total_checklist_items&quot;: &quot;48&quot;,
                      &quot;total_completed_checklist_items&quot;: &quot;0&quot;,
                      &quot;label&quot;: {
                          &quot;#FF3B30&quot;: {
                              &quot;ticket_label_name&quot;: &quot;&quot;,
                              &quot;ticket_color_code&quot;: &quot;#FF3B30&quot;
                          }
                      },
                      &quot;people&quot;: []
                  }
              }
          },
          {
              &quot;ticket_category_id&quot;: &quot;677&quot;,
              &quot;ticket_category_name&quot;: &quot; Testing 500&quot;,
              &quot;ticket_category_order&quot;: &quot;1&quot;,
              &quot;tickets&quot;: {
                  &quot;927&quot;: {
                      &quot;ticket_id&quot;: &quot;927&quot;,
                      &quot;ticket_title&quot;: &quot;EDI Project Template with attachments&quot;,
                      &quot;ticket_order&quot;: &quot;1&quot;,
                      &quot;due_date&quot;: &quot;0000-00-00 00:00:00&quot;,
                      &quot;created_date&quot;: &quot;2018-05-16 10:01:04&quot;,
                      &quot;edited_date&quot;: &quot;2018-05-17 02:56:38&quot;,
                      &quot;updated_date&quot;: &quot;2018-05-17 02:56:38&quot;,
                      &quot;is_complete&quot;: &quot;0&quot;,
                      &quot;total_comment&quot;: &quot;0&quot;,
                      &quot;total_attachment&quot;: &quot;10&quot;,
                      &quot;total_checklist_items&quot;: &quot;48&quot;,
                      &quot;total_completed_checklist_items&quot;: &quot;0&quot;,
                      &quot;label&quot;: {
                          &quot;#D4891C&quot;: {
                              &quot;ticket_label_name&quot;: &quot;IN PROGRESS&quot;,
                              &quot;ticket_color_code&quot;: &quot;#D4891C&quot;
                          }
                      },
                      &quot;people&quot;: []
                  }
              }
          },
  </code></pre>
  <p>And below is the code I have done, I using php mysql one to many relationship get all the data to be flat array, and then below code is convert single flat array into three multidimension array, but i meet a bottleneck. Please help to review my code to point out which part I need to change to become my expected result.</p>
  <pre><code>  $result = array();
      foreach($total_count as $Key =&gt; $Value){
          $ticketCatId = $Value['ticket_category_id'];
          $ticketId = $Value['ticket_id'];
          $ticketColorCode = $Value['ticket_color_code'];
          $ticketMember = $Value['user_id'];
      
          $result[$ticketCatId]['ticket_category_id'] = $Value['ticket_category_id'];
          $result[$ticketCatId]['ticket_category_name'] = $Value['ticket_category_name'];
          $result[$ticketCatId]['ticket_category_order']  = $Value['ticket_category_order'];
  
          if(!isset($result[$ticketCatId]['tickets'])) {
              $result[$ticketCatId]['tickets'] = array();
          }
  
          // this code is append the ticket ID
          if($ticketId &amp;&amp; !isset($result[$ticketCatId]['tickets'][$ticketId])) {
              $ticket = array(
                  'ticket_id'                         =&gt; $Value['ticket_id'],
                  'ticket_title'                      =&gt; $Value['ticket_title'],
                  'ticket_order'                      =&gt; $Value['ticket_order'],
                  'due_date'                          =&gt; $Value['due_date'],
                  'created_date'                      =&gt; $Value['created_date'],
                  'edited_date'                       =&gt; $Value['edited_date'],
                  'updated_date'                      =&gt; $Value['updated_date'],
                  'is_complete'                       =&gt; $Value['is_complete'],
                  'total_comment'                     =&gt; $Value['total_comment'],
                  'total_attachment'                  =&gt; $Value['total_attachment'],
                  'total_checklist_items'             =&gt; $Value['total_checklist_items'],
                  'total_completed_checklist_items'   =&gt; $Value['total_completed_checklist_items'],
                  'label' =&gt; array(),
                  'people' =&gt; array()
                  
              );
              $result[$ticketCatId]['tickets'][$ticketId] = $ticket;
          }
  
          if($ticketColorCode &amp;&amp; isset($result[$ticketCatId]['tickets'][$ticketId]) &amp;&amp; !isset($result[$ticketCatId]['tickets'][$ticketId]['label'][$ticketColorCode])) {
              $ticketColor = array(
                  'ticket_label_name' =&gt; $Value['ticket_label_name'],
                  'ticket_color_code' =&gt; $Value['ticket_color_code']
              );
              $result[$ticketCatId]['tickets'][$ticketId]['label'][$ticketColorCode] = $ticketColor;
          }
  
          if($ticketMember &amp;&amp; isset($result[$ticketCatId]['tickets'][$ticketId]) &amp;&amp; !isset($result[$ticketCatId]['tickets'][$ticketId]['people'][$ticketMember])) {
              $ticketPeople = array(
                  'user_id' =&gt; $Value['user_id'],
                  'photo' =&gt; $Value['photo']
              );
              $result[$ticketCatId]['tickets'][$ticketId]['people'][$ticketMember] = $ticketPeople;
          }
  }
  
      dd(json_encode([&quot;data&quot;=&gt;$result]));
  </code></pre>