Remove "undefined offset" PHP notice by testing if key exists in array