未定义的偏移误差,但偏移不是未定义 [英] Undefined offset error, but offset is not undefined
本文介绍了未定义的偏移误差,但偏移不是未定义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到:
Notice: Undefined offset: 0
在我的code,不过,我可以的print_r我试图让元素和它的明确的规定。
in my code, however I can print_r the element I am trying to get and its clearly defined.
function get_members($entries_found) {
$members = $entries_found[0]['member'];
...
}
如果我的print_r($成员),我得到预期的输出,但我仍然得到通知。
If I print_r($members) I get the expected output, however I'm still getting the Notice.
任何线索?
推荐答案
不要
var_dump($entries_found);
要检查阵列确实具有零偏移。其他的事情你可以尝试将CH375复位数组指针
To check that the array does indeed have an offset of zero. Other things you can try would be reseting the array pointer
reset($entries_found);
检查,如果它的设置第一个
of checking if it's set first
if (isset($entries_found[0]['member'])) // do things
如果一切都失败了,你可以只是苏preSS该通知
If all else fails you could just supress the notice with
$members = @$entries_found[0]['member'];
这篇关于未定义的偏移误差,但偏移不是未定义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文