do_for_each_ref_in_arrays(): new function