restored is_array check

as $val may be an array or not