Return to Snippet

Revision: 42583
at March 7, 2011 21:44 by chopbust


Initial Code
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);

Initial URL


Initial Description
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.

Initial Title
Set a minimum value

Initial Tags


Initial Language
PHP