PHPize Online / SQLize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
Copy Clear
Copy Format Clear
<?php $in = [1,2,3,5,6,7,8,9]; $cur = array_shift($in); $seq = [$cur]; $max_l = 1; $l = 1; echo $cur; foreach($in as $el) { if ($el - $cur === 1) { $cur = $el; $seq[] = $cur; $l++; } else { $max_l = max($max_l, $l) $l = 1; } } echo $max_l;
Show:  
Copy Clear