Fixed a php warning when $val is an array on line 305.