先看下效果,如下图所示,需要用到三维数组:
代码如下:
<?php
$array1=array(
"市场部10月份工资表"=> array(
array(1,"高某","市场部经理","5000.00"),
array(2,"冯某","普通职员","3000.00"),
array(3,"李某","普通职员","2400.00"),
),
"产品部10月份工资表"=>array(
array(1,"王某","产品部经理","6000.00"),
array(2,"周某","普通职员","4000.00"),
array(3,"吴某","普通职员","3200.00"),
),
"财务部10月份工资表"=>array(
array(1,"郑某","财务部经理","4500.00"),
array(2,"孙某","普通职员","2000.00"),
array(3,"赵某","普通职员","1500.00"),
),
);
?>
<!doctype html>
<html>
<head>
<title>市场部10月份工资表</title>
<meta charset="utf-8">
</head>
<body>
<div style="text-align:center;">
<?php foreach($array1 as $key =>$value){echo $key;?>
<table width="500" border="1" style="margin:0 auto">
<th>编号</th>
<th>姓名</th>
<th>职位</th>
<th>工资</th>
<?php foreach($value as $value1){?>
<tr>
<?php foreach($value1 as $value2){?>
<td><?php echo $value2;?></td>
<?php }?>
</tr>
<?php }?>
</table>
<br>
<?php }?>
</div>
</body>
</html>