我有這樣的代碼,但是當我運行它,它給我的錯誤(注:未定義抵消:1 C:\ WAMP \ WWW \ test3.php上線$str[$row['term_no']] += ",".$row['code'];
)如何使用數組在PHP語言
如何我可以解決這個問題嗎?
<?php
$con = mysqli_connect('localhost', 'root', '');
mysqli_select_db($con, "uoh");
$q = " SELECT * FROM `degree_plan` LEFT JOIN courses ON
degree_plan.course_number=courses.course_number
where major='COE'";
$result = mysqli_query($con, $q);
if ($result) {
$str = [];
while ($row = mysqli_fetch_array($result)) {
{
$str[$row['term_no']] += "," . $row['code'];
}
foreach ($str as $key => $value) {
echo $value;
echo $key;
}
}
}
?>
'如果一切失敗,RTFM' .... –
閱讀[PHP數組(http://php.net/manual/e N/language.types.array.php)。 – axiac
我不知道該行試圖做什麼......但array_push()可能是關閉的。 –