目前,每個td ../ td只打印一行,這使得源代碼非常難以閱讀,任何方式我都可以在新行上打印每個td ../ td元素,使其更具可讀性。如何在PHP中使用新行打印每個..</td>?
感謝您的回覆。我試過了這個突破,但它在屏幕上打印,需要放在這裏,但在哪裏?
$entries[$i] = '<td>'.$id[$i] .'</td>';
$entries[$i] .= '<td>'.$username[$i].'</td>';
$entries[$i] .= '<td>'.$first_name[$i].'</td>';
進一步編輯:
相關的HTML
<!-- Main hero unit for a primary marketing message or call to action -->
<div class="hero-unit">
<div class="row">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>First Name</th>
<th>Last Name</th>
<th>Username</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
</tr>
<tr>
<td>2</td>
<td>Jacob</td>
<td>Thornton</td>
<td>@fat</td>
</tr>
<tr>
<td>3</td>
<td>Larry</td>
<td>the Bird</td>
<td>@twitter</td>
</tr>
</tbody>
</table>
<table class="table table-bordered">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>First Name</th>
<th>Last Name</th>
<th>Email Address</th>
<th>Country</th>
<th>Referrer</th>
</tr>
</thead>
<tbody>
<tr>
<?php
if (isset($content) && !empty($content) && is_array($content)) {//2
$i = 0;
$entries = array();
while(array_key_exists($i, $content)) {//1
$entries[$i] = "\n" .'<td>'.$id[$i] .'</td>';
$entries[$i] .= "\n" .'<td>'.$username[$i].'</td>';
$entries[$i] .= "\n" .'<td>'.$first_name[$i].'</td>';
$entries[$i] .= "\n" .'<td>'.$last_name[$i].'</td>';
$entries[$i] .= "\n" .'<td>'.$email_address[$i].'</td>';
$entries[$i] .= "\n" .'<td>'.$country[$i].'</td>';
$entries[$i] .= "\n" .'<td>'.$where_about[$i].'</td>';
//$entries[$i] .= '<td>'.$sample[$i].'</td>';
echo $entries[$i];
$i++;
}//1
}//2
?>
</tr>
</tbody>
</table>
您是否能夠通過下面的任何答案解決此問題,還是仍然打開? – sg3s 2012-04-08 12:20:33