在我当前的 PHP 脚本中出现此错误: undefined offset :1
我的代码在这里:
$query = "SELECT item_id, username, item_content FROM updates ORDER BY update_time DESC LIMIT " . $start . ", " . $number_of_posts;
$result = mysql_query($query) or die(mysql_error());
while($row = mysql_fetch_assoc($result)) {
preg_match("/<p>(.*)<\/p>/",$row['item_content'],$matches);
$row['item_content'] = strip_tags($matches[1]);
$posts[] = $row;
}
如果您知道是什么原因造成的,那么在下面发帖会很有帮助。谢谢! :)
最佳答案
代替
$row['item_content'] = strip_tags($matches[1]);
尝试
if (isset($matches[0]) && isset($matches[0][1]))
$row['item_content'] = strip_tags($matches[0][1]);
else
$row['item_content'] = '';
关于php - undefined offset : 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5424236/