PHP loops to check that a set of numbers are consecutive
<p>I'm trying to loop through a set of records, all of which have a "number" property. I am trying to check if there are 3 consecutive records, e.g 6, 7 and 8. </p>

<p>I think i'm almost there with the code below, have hit the wall though at the last stage - any help would be great!</p>

<pre><code>    $nums = array();

                    while (count($nums &lt;= 3))
                    {
                        //run through entries (already in descending order by 'number'
                        foreach ($entries as $e)
                        {
                            //ignore if the number is already in the array, as duplicate numbers may exist
                            if (in_array($e-&gt;number, $num))
                                continue;
                            else
                            {
                                //store this number in the array
                                $num[] = $e-&gt;number;
                            }

//here i need to somehow check that the numbers stored are consecutive
                        }
                    }
</code></pre>
