I want to know how to go about solving this equation: I have a set of numbers - for example :
130 136 142 148 149 159
( I have highlighted the value of interest 148).
The difference between the values are :
6 6 6 1 10 ( I have highlighted the value of interest 1 ).
The reason that 148 is the first value of interest is because, value to value, it has the smallest number (1).
The Scenario
The set of numbers are inputs which are submitted to a database. Then I've started the calculation like this :
$st1 = $userRow['val2(130)'] - $userRow['val1(136)'];
$st2 = $userRow['val3(142)'] - $userRow['val2(130)'];
$st3 = $userRow['val4(148)'] - $userRow['val3(142)'];
$st4 = $userRow['val5(149)'] - $userRow['val4(148)'];
$st5 = $userRow['val6(159)'] - $userRow['val5(149)'];
Which gives me the differences - value to value, and below gives me the min value.
$val = min($st1, $st2, $st3, $st4, $st5);
So after that how do I isolate 148 or $userRow['val4(148)'] as the value of interest? Bearing in mind that a set of numbers could be any combination, but that the complete range will always be increasing, for example:
130 140 149 159 167 169
110 120 130 132 150 160
P.S I know the syntax is messy - but it's just for explanation purposes. Thanks