我正在尝试循环遍历一组记录,所有记录都有一个“number”属性。我想检查是否有3个连续的记录,例如6、7和8。
我认为下面的代码已经接近成功了,但在最后阶段遇到了困难 - 任何帮助都将是极好的!
$nums = array();
while (count($nums <= 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->number, $num))
continue;
else
{
//store this number in the array
$num[] = $e->number;
}
//here i need to somehow check that the numbers stored are consecutive
}
}
isConsecutive([1,3,0,0])
现在返回什么? - miken32