n_spans function

Count the number of spans in a phinterval