if(isset($assoc[0]['val'][1]['val'][4]['val'][0]['val'][0]['val']) && isset($assoc[0]['val'][1]['val'][4]['val'][0]['val'][0]['val'])) {
That's a hell of an if statement on line 235, which is funny because you're running an isset() on the same array key twice.
Ah accidental public code reviews.