我正在尝试使用此关联数组将关联数组中的项目显示到一个两列表中
foreach($this->inventory as $ID => $Info)
。
"<table width ='100%'>\n";
foreach($this->inventory as $ID => $Info) {
echo"<tr>";
echo"<td>".$Info['name'] <br>$Info['description']." </td>";
echo"<td>".$Info['name'] <br>$Info['description']."</td>";
echo"</tr>";
}
</table>
问题是它在每一行上显示每个项目两次。我希望它显示如下:
------------------------------------------------------------------
|Name: shoes |Name: bag
|Description: nike |Description: swing bag
-----------------------------------------------------------------
|Name: socks |Name: ear phones
|Description: black and white |Description: beats
-----------------------------------------------------------------
|Name: earrings |Name: phone
|Description: diamond studs |Description: blackberry
但我得到了这个:
------------------------------------------------------------------
|Name: shoes | Name: shoes
|Description: nike | Description: nike
-----------------------------------------------------------------
|Name: bag | Name: bag
|Description: swing bag |Description: swing bag
-----------------------------------------------------------------
|Name: ear phones |Name: ear phones
|Description: beats |Description: beats