21,887
社区成员
发帖
与我相关
我的任务
分享
$a=array('27845615','47234567','78786781','60175123');
foreach($a as $v) {
echo fountMax($v). '<br/>';
}
/*
3
6
3
3
*/
function fountMax($str)
{
$arr = str_split($str);
$max = 1;
$tmp = 1;
for($i=1; $i<count($arr); $i++) {
if($arr[$i-1]+1 == $arr[$i]) {
$tmp++;
$max = $tmp>$max ? $tmp : $max;
}
else {
$tmp = 1;
}
}
return $max;
}