study.prl85.com
Function – convert list of numbers (comma separated) to range (compress)
Example: 1, 3, 4, 5, 6 to 1,3-6 Implementation using PHP (For other language, you just need to modify some part of it)