Need help on array

I am trying to create a form that users can input some values. While these values are run through a function there are a few math problems that happen. Once I get part way through the function I need to compare the value to a table or array. Here is an example:
myvalue = 7.19
myvalue needs compared to the values in column kva@140% in a table, or array. Like this:
kva - vdft - kva@140%
5 - .446 - 6.30
10 - .314 - 9.45
so if myvalue isn’t in the kva@140% column or array it needs to increase itself to the next highest value that is, then I need a new value from the corresponding value of vdft to continue my function. If anyone would be interested in helping me accomplish this it would be greatly appreciated. I can send the formula or the function that I have so far.
Thanks

Assuming you can pull out the data from your kva@140% column into an array:

$smallestdiff = $myvalue;
$indexkey = -1;

if (in_array($myvalue, $kva140_array)) {
  // value found
} else {
  for ($i = 0; $i < count($kva140_array); $i++) {
    $diff = $kva140_array - $myvalue;
    if ($diff > 0 && $diff < $smallestdiff) {
      $smallestdiff = $diff;
      $indexkey = $i;
    }
  }
}
Sponsor our Newsletter | Privacy Policy | Terms of Service