Php 将来自不同foreach循环的值组合到一个数组中
我试图将两个Php 将来自不同foreach循环的值组合到一个数组中,php,arrays,Php,Arrays,我试图将两个foreach()循环值组合到一个数组中,并将其显示在一个表中。它们都有相同的字段,但是如何在一个表中显示它,而不是在两个不同的表中显示它呢 <tr> <th> ID </th> <th> Transaction Type </th> </tr> <tbody> <?php $ch = new CommissionHelper($rep); $data
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>
身份证件
交易类型
注意:-从代码中间删除
ID交易类型
fypforstack很高兴为您提供帮助。干杯:):)