PHP - 不能使用标量作为数组警告
2022-08-30 09:27:10
我有以下代码:
$final = array();
foreach ($words as $word) {
$query = "SELECT Something";
$result = $this->_db->fetchAll($query, "%".$word."%");
foreach ($result as $row)
{
$id = $row['page_id'];
if (!empty($final[$id][0]))
{
$final[$id][0] = $final[$id][0]+3;
}
else
{
$final[$id][0] = 3;
$final[$id]['link'] = "/".$row['permalink'];
$final[$id]['title'] = $row['title'];
}
}
}
代码似乎工作正常,但我收到此警告:
Warning: Cannot use a scalar value as an array in line X, Y, Z (the line with: $final[$id][0] = 3, and the next 2).
谁能告诉我如何解决这个问题?