How to find missing values in a sequence with PHP?

KOTS

New Member
Suppose you have an array "value => timestamp". The values are increasing with the time but they can be reset at any moment.For example :\[code\]$array = array(1 => 6000,2 => 7000,3 => 8000,7 => 9000,8 => 10000,9 => 11000,55 => 1000,56 => 2000,57 => 3000,59 => 4000,60 => 5000,);\[/code\]I would like to retrieve all the missing values from this array. This example would return :\[code\]array(4,5,6,58)\[/code\]I don't want all the values between 9 and 55 because 9 is newer than the other higher values.In real condition the script will deal with thousands of values so it need to be efficient.Thanks for your help!UPDATE :The initial array can be ordered by timestamps if it is easier for the algorithm.UPDATE 2 :In my example the values are UNIX timestamps so they would look more like this : 1285242603 but for readability reason I simplified it.
 
Back
Top