1
我的問題是我怎樣才能解決以下示例代碼中未定義的偏移錯誤?收到如何解決未知代碼中的錯誤代碼如下
誤差在屏幕上顯示:
Notice: Undefined offset: 0 in ... on line 572 Notice: Undefined offset: 0 in ... on line 572
Question: :
Notice: Undefined offset: 1 in ... on line 572
Notice: Undefined offset: 1 in ...on line 572
Question: :
下面的代碼
$questions = array();
while ($selectedstudentanswerstmt->fetch()) {
$arrQuestionNo = array();
$arrQuestionContent = array();
$arrQuestionNo[] = $detailsQuestionNo;
$arrQuestionContent[] = $detailsQuestionContent;
$questions[] = $arrQuestionNo;
$questions[] = $arrQuestionContent;
}
<?php
foreach ($questions as $key=>$question) {
//ERROR APPEARS IN LINE BELOW:
echo '<p><strong>Question:</strong> ' .htmlspecialchars($arrQuestionNo[$key]). ': ' .htmlspecialchars($arrQuestionContent[$key]). '</p>' . PHP_EOL;
}
?>