- var_dump: documentation ( source)
- end: documentation ( source)
<?php
$arr1 = [1,2,3,4,45,78,110];
$longestSeq = array();
$tempSeq = array();
$countSeq = 0;
$start = true;
foreach($arr1 as $arr) {
if($start){
$tempSeq[] = $arr;
} else {
if(end($tempSeq)+1 == $arr){
$tempSeq[] = $arr;
} else {
$longestSeq = $tempSeq;
$tempSeq = array();
}
}
}
var_dump($longestSeq);