[RESOLVED] How to properly handle "Undefined offset"?
What is the correct way to fix this?
The only option I have right now it to disable that particular notice in php.ini.
I am using is_null (but atm is_set would also work as far as functionality), but just sending that undefined offset using is_null sets off the error. Any trick to fixing this? Right now I am getting like 30-40, and I just started coding :P
Re: How to properly handle "Undefined offset"?
I assume you are using strict mode. This is a good thing. Don't disable warnings; fix the code.
You can use isset() or array_key_exists() to determine if an offset exists. There is a very subtle difference between the two which doesn't matter in most cases.
is_null() will not work — this actually attempts to read the array offset, and so fails if it does not exist.
Re: How to properly handle "Undefined offset"?
weird, thought I had tried isset, but just tried it again and it worked, tnx.