Page 1 of 1

Array => range string function?

Posted: Sun Jul 04, 2010 12:41 am
by jraede
Does anyone know of a good function that takes an array of numbers and turns it into a string representing the ranges?

E.g., array(1,3,4,5,8,9,10,11) would be turned into 1, 3-5, 8-11.

I'm sure there's some out there already and I don't want to reinvent the wheel, but in the event that I have to, what do you think is the best approach?