将不同的foreach循环的值结合到数组中



我试图将两个foreach()循环值组合到一个数组中,并将其显示在单个表中。他们两个都有相同的字段,但是如何在单个表中显示它而不是有两个不同的表?

<tr>
   <th> ID </th>
   <th> Transaction Type </th>
</tr>
<tbody>
   <?php 
      $ch = new CommissionHelper($rep);
      $data = $ch->getTransactionRecords($member);
        foreach ($data as $record ) {
      $d = ((object)$record);
      $pt = round($d->point, 2);
      ?>
   <tr>
      <td><?php echo $d->id;?></td>
      <td><?php echo $d->type;?></td>
   </tr>
   <?php
      }
      ?>
</tbody>
<tr>
   <th> ID </th>
   <th> Transaction Type </th>
</tr>
<tbody>
   <?php 
      $query = "SELECT * FROM invoice_withdraw_debit_card where user_ID like $id";
      $data = $MySQLi_CON->query($query);
      foreach ($data as $key ) {      
      ?>
   <tr>
      <td><?php echo $key['invoice_ID'];?></td>
      <td><?php echo $key['type'];?></td>
   </tr>
   <?php
      }
      ?>
</tbody>

您可以像下面的那样实现它: -

<tr>
   <th> ID </th>
   <th> Transaction Type </th>
</tr>
<tbody>
   <?php 
      $ch = new CommissionHelper($rep);
      $data = $ch->getTransactionRecords($member);
        foreach ($data as $record ) {
      $d = ((object)$record);
      $pt = round($d->point, 2);
      ?>
   <tr>
      <td><?php echo $d->id;?></td>
      <td><?php echo $d->type;?></td>
   </tr>
   <?php
      }
      ?>
   <?php 
      $query = "SELECT * FROM invoice_withdraw_debit_card where user_ID like $id";
      $data = $MySQLi_CON->query($query);
      foreach ($data as $key ) {      
      ?>
   <tr>
      <td><?php echo $key['invoice_ID'];?></td>
      <td><?php echo $key['type'];?></td>
   </tr>
   <?php
      }
      ?>
</tbody>

注意: - 从代码中间删除</tbody><tr><th> ID </th><th> Transaction Type </th></tr><tbody>