Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- array (
- 0 => '1',
- 1 => '2',
- 2 => '3',
- 3 => '4',
- 4 => '5',
- 5 => '6',
- 6 => '7',
- 7 => '8',
- 8 => '9',
- 9 => '11',
- 10 => '12',
- 11 => '13',
- )
- $arr = [1, 2, 5, 6, 7, 9, 11];
- $missedNumbers = [];
- foreach ($arr as $id => $number) {
- if (!isset($arr[$id + 1])) {
- continue;
- }
- if ($arr[$id + 1] - $number !== 1) {
- for ($i = 1; $i < $arr[$id + 1] - $number; $i++) {
- $missedNumbers[] = $arr[$id + 1] - $i;
- }
- }
- }
- Array
- (
- [0] => 4
- [1] => 3
- [2] => 8
- [3] => 10
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement