时间:2021-07-01 10:21:17 帮助过:42人阅读
$arr = array(4,7,0,2,4,5,6,9,1,2,3,4); $counter = 1; for($i = 0; $i < count($arr) - 1; $i ++) { if ($arr[$i + 1] == $arr[$i] + 1) { $counter ++; if ($counter == 3) { echo "找到连续值的数字:\n[".($i - 1)."]=>{$arr[$i - 1]}\n[".$i."]=>{$arr[$i]}\n[".($i + 1)."]=>{$arr[$i + 1]}\n"; } } else $counter = 1; }