I am trying to evaluate the content of an array. The array contain water temperatures submitted by a user.

The user submits 2 temperaures, one for hot water and one for cold water.

What I need is to evaluate both array items to find if they are within the limits, the limits are "Hot water: between 50 and 66", "Cold water less than 21".

If either Hot or Cold fail the check flag the Status "1" or if they both pass the check flag Status "0".

Below is the code I am working with:

```
$row_WaterTemp['HotMin'] = "50";
$row_WaterTemp['Hotmax'] = "66";

$SeqWaterArray new(array);

$SeqWaterArray = array("58", "21");

foreach($SeqWaterArray as $key => $val) {
    $fields[] = "$field = '$val'";
    if($key == 0) { 
        if($val < $row_WaterTemp['HotMin'] || $val > $row_WaterTemp['Hotmax']) {
            $Status = 1;
            $WaterHot = $val;
        } else {
            $Status = 0;
            $WaterHot = $val;
        }

    }

    if($key == 1) {
        if($val > $row_WaterTemp['ColdMax']) {
            $Status = 1;
            $WaterCold = $val;
        } else {
            $Status = 0;
            $WaterCold = $val;
        }
    }   

}

```

My question is:

When I run the script the array key(0) works but when the array key(1) is evaluted the status flag for key(1) overrides the status flag for key0.
If anyone can help that would be great.
Many thanks for your time.