我有一个关于数组乘法和表格形式显示的任务,我的老师给我提供了数组形式的数据,并表示将它显示在表格中形式,也乘以项目**数量和价格**,并在表中显示....我已经以表格形式显示数组,但我无法产生数量和价格?有人帮忙吗?如何在数组上执行计算并以表格形式显示
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$ProductsTest = array("1001" => array("Name" => "LCD","Desc" => "Sony","Qty" =>10,"Price" => 2000),
"1002" => array("Name" => "Mouse","Desc" => "Dell","Qty" =>3,"Price" => 300),
"1003" => array("Name" =>"Mouse","Desc" =>"a4Tech","Qty" =>3,"Price" =>300),
"1004" => array("Name" =>"USB","Desc" =>"Kingstton","Qty" =>15,"Price" =>700),
"1005" => array("Name" =>"HeadPhone","Desc" =>"a4Tech","Qty" =>7,"Price" =>3000));
$no_of_ele = count($ProductsTest);
echo '<br><br>';
echo ' <table border="2", bgcolor="white",width="100%">
<tr>
<th>Name</th>
<th>Brand</th>
<th>QTY</th>
<th>price</th>
<th>totalamount</th>
</tr>';
foreach($ProductsTest as $values)
{
echo '<tr>';
foreach($values as $key)
{
echo '<td>'.$key.'</td>';
}
echo '</tr>';
}
echo '</table>';
?>
</body>
</html>
这是我的输出至今
thnku非常适合我:) –
太棒了!那么请接受我的回答。 – Naincy