<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$table = array ("1", "2", "3", "4", "5");
$count = count($table);
echo "<table border='1'>";
$rows = 5;
for($i=0; $i <= $count; $i = $i + $rows)
{
echo "<tr>";
for($z = 0; $z < $rows; $z++)
{
if ($table[$i + $z] !=0)
echo "<td>This is row {$table[$i + $z]}</td></tr>";
else
echo "<td> </td></tr>";
}
}
echo "</table>"
?>
</body>
</html>
這是我一直在努力工作一段時間的代碼,而其他一切正常的情況下,運行時會出現問題。它顯示了我所想要的桌子上,但在桌子底下它的帖子:未定義偏移量:5
Notice: Undefined offset: 5 in [file location] on line 22
Notice: Undefined offset: 6 in [file location] on line 22
Notice: Undefined offset: 7 in [file location] on line 22
Notice: Undefined offset: 8 in [file location] on line 22
Notice: Undefined offset: 9 in [file location] on line 22
我知道問題是圍繞價值,但不管如何我把它變成,它要麼刷新「= 0!」全部努力或重複相同的消息。
如果你提供一些你在做什麼以及它爲什麼工作的解釋,答案會更有幫助。 – 2013-12-10 16:17:55