2 回答
TA贡献1845条经验 获得超8个赞
<?php
$data = file_get_contents('test.json');
$data =json_decode($data,TRUE);
$dataA= array();
foreach($data as $singleArray){
array_push($dataA, $singleArray['Line']);
}
$arrayChunks= array_chunk($dataA, 3);
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<table>
<thead>
<th>Names</th>
<th>Department</th>
</thead>
<tbody>
<?php
foreach($arrayChunks as $array){
if(empty($array[0]) || empty($array[1]) || empty($array[2]))continue;
?>
<tr>
<td><?php echo $array[1]; ?></td>
<td><?php echo $array[2]; ?></td>
</tr>
<?php
}
?>
</tbody>
</table>
</body>
</html>
嗨,它正是你正在寻找的。尝试检查这一点并根据需要设置输出。它只是一个想法,你肯定可以用这个来改善你的问题。谢谢
TA贡献1801条经验 获得超15个赞
这就是我想要的结果,作为有问题的图像给出
$data = json_decode($data , true);
$k = 1;
$l=1;
$html .='<table class="table table-striped table-bordered" border="1">';
foreach($data as $combine){
if($combine['RowIndex']==$k){
$html .='<tr>';
foreach($data as $com){
if($com['RowIndex']==$l){
$html .='<td>'.$com['Line'].'</td>';
}
}
$html .='</tr>';
//$k=$combine['RowIndex'];
$k++;
$l++;
}
}
$html .='</table>';
print_r($html);
die;
- 2 回答
- 0 关注
- 80 浏览
添加回答
举报