SHARE
TWEET

Untitled

a guest Jun 20th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. array (
  2.   0 => '1',
  3.   1 => '2',
  4.   2 => '3',
  5.   3 => '4',
  6.   4 => '5',
  7.   5 => '6',
  8.   6 => '7',
  9.   7 => '8',
  10.   8 => '9',
  11.   9 => '11',
  12.   10 => '12',
  13.   11 => '13',
  14. )
  15.      
  16. $arr = [1, 2, 5, 6, 7, 9, 11];
  17.     $missedNumbers = [];
  18.  
  19.     foreach ($arr as $id => $number) {
  20.         if (!isset($arr[$id + 1])) {
  21.             continue;
  22.         }
  23.  
  24.         if ($arr[$id + 1] - $number !== 1) {
  25.             for ($i = 1; $i < $arr[$id + 1] - $number; $i++) {
  26.                 $missedNumbers[] = $arr[$id + 1] - $i;
  27.             }
  28.         }
  29.     }
  30.      
  31. Array
  32. (
  33.     [0] => 4
  34.     [1] => 3
  35.     [2] => 8
  36.     [3] => 10
  37. )
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top