[英]How to print php arrays in Html?
I have a php file and do all the processing to save information in arrays.Then i write Html to represent the data from the Arrays.I want each row of the table to have the i-element of the arrays but until now i get only最后一行,所以我想我的 for 循环不起作用。这是我的代码
?>
<!DOCTYPE html>
<html>
<head>
<style>
table {
font-family: arial, sans-serif;
border-collapse: collapse;
width: 100%;
}
td, th {
border: 1px solid #dddddd;
text-align: left;
padding: 8px;
}
tr:nth-child(even) {
background-color: #dddddd;
}
</style>
</head>
<body>
<h2>XML file Data</h2>
<table>
<tr>
<th>Lesson Title</th>
<th>ClassRoom</th>
<th>Day</th>
<th>Time</th>
<th>Professor</th>
</tr>
<?php for ($i = 0; $i < sizeof($lessonTitleArray); $i++) : ?>
<tr>
<td><?php echo $lessonTitleArray[$i]; ?></td>
<td><?php echo $classRoomArray[$i]; ?></td>
<td><?php echo $DayArray[$i]; ?></td>
<td><?php echo $TimeArray[$i]; ?></td>
<td><?php echo $professorArray[$i]; ?></td>
</tr>
<?php endfor; ?>
</table>
</body>
</html>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.