help with converting javascript function to php
<p>My javascript isnt so great, but i found a brilliant looking function <a href="http://stackoverflow.com/questions/2270910/how-to-convert-sequence-of-numbers-in-an-array-to-range-of-numbers/2270987#2270987">here</a></p>

<p>I'm not sure what to do with this bit:</p>

<pre><code>var ranges = [], rstart, rend;
</code></pre>

<p>full function:</p>

<pre><code>function getRanges(array) {
  var ranges = [], rstart, rend;
  for (var i = 0; i &lt; array.length; i++) {
    rstart = array[i];
    rend = rstart;
    while (array[i + 1] - array[i] == 1) {
      rend = array[i + 1]; // increment the index if the numbers sequential
      i++;
    }
    ranges.push(rstart == rend ? rstart+'' : rstart + '-' + rend);
  }
  return ranges;
}

getRanges([2,3,4,5,10,18,19,20]);
// returns ["2-5", "10", "18-20"]
getRanges([1,2,3,5,7,9,10,11,12,14 ]);
// returns ["1-3", "5", "7", "9-12", "14"]
getRanges([1,2,3,4,5,6,7,8,9,10])
// returns ["1-10"]
</code></pre>
