当前位置: 动力学知识库 > 问答 > 编程问答 >

php - Error like Undefined offset: 3, issue in project?

问题描述:

This question already has an answer here:

  • undefined offset PHP error

    4 answers

网友答案:

The error "Undefined Offset" means you are trying to access an index of an array that does not exist.

My best guess is that the offending code is:

if($sites2[$i] == $s_id){
    echo "checked";
}

And an Undefined offset of 3 is telling you that $sites2[3] does not exist. Instead, you could try something like:

if(isset($sites2[$i]) && $sites2[$i] == $s_id){
    echo "checked";
}
分享给朋友:
您可能感兴趣的文章:
随机阅读: