/ Published in: PHP
Method takes the amount and compares with the lowest/highest value and assigns that variable with the lowest/highest value. Good for setting the bar for lowest/highest value found in a set of value.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function check_max($value1, $value2) { if ((float)$value2 > (float)$value1) $max = (float)$value2; else $max = (float)$value1; return $max; } function check_min($value1, $value2) { if ($value2 != 0) { //dump(array($value1,$value2)); if ((float)$value2 < (float)$value1) $min = (float)$value2; else $min = (float)$value1; return $min; } else return $value1; } //usage: $max = check_max($max, $value_to_compare);