Regular numbers
① $number = 1234784;
The regular matching result is: 1234
② $number = 389456723;
The regular matching result is: 4567
Reply to discussion (solution)
No sequential numbers can be matched only with regular
No sequential numbers can be matched only with regular
What solution should be used?
Is the first 78 not a continuous one? is the second 89 and 23 not a continuous one? Why not?
Does "386387" count as continuous? Do you want to match?
① $number = 1234784;
The regular matching result is: 1234
② $number = 389456723;
The regular matching result is: 4567
It seems to match 4 consecutive bits, if so, it's just a few things:
$s = 389456723;
4 consecutive Bits
$r = ' (1234|2345|3456|4567|5678|6789) ';
Preg_match_all ('/'. $r. '/', $s, $m);
Print_r ($m [0]);
Over 3 consecutive positions
$r = ' (1234|2345|3456|4567|5678|6789|123|234|345|456|567|678|789) ';
Preg_match_all ('/'. $r. '/', $s, $m);
Print_r ($m [0]);
2 or more, you don't have to demonstrate.
It seems to match 4 consecutive bits, if so, it's just a few things:
$s = 389456723;
4 consecutive Bits
$r = ' (1234|2345|3456|4567|5678|6789) ';
Preg_match_all ('/'. $r. '/', $s, $m);
Print_r ($m [0]);
Over 3 consecutive positions
$r = ' (1234|2345|3456|4567|5678|6789|123|234|345|456|567|678|789) ';
Preg_match_all ('/'. $r. '/', $s, $m);
Print_r ($m [0]);
More than 2 people do not have to demonstrate it is this! good!