Location: PHPKode > scripts > Range Compare > range-compare/class.rangeCompare.php
<?
// Author: Nathan R Leggatt//
# Contact: hide@address.com
#
# If you find this script useful or are using it for one of your projects
# please send me an email telling me a little about the project
# and how useful the script was to you.
#
# Date: June 16th 2003
#
############################################################

class rangeCompare {

	var $nTopRange;
	var $nBotRange;
	var $nRangeValue;
	var $nCompValue;
	var $nStaticValue;

	function rangeCompare() 
	{

	}

	function compare ($nCompValue, $nStaticValue, $nRangeValue)
	{
		// Define Top And Bottom Ranges/
		$this->nTopRange = $nStaticValue+$nRangeValue;
		$this->nBotRange = $nStaticValue-$nRangeValue;

		if (($nCompValue <= $this->nTopRange) && ($nCompValue >= $this->nBotRange))
		{
			return 0; // The Compared Value is Within the Range of the Static Value //
		}

		if ($nCompValue < $this->nBotRange)
		{ 
			return -1; // The Compared Value is Less than the Range of the Static Value //
		}

		if ($nCompValue > $this->nTopRange)
		{ 
			return 1; // The Compared Value is Greater than the Range of the Static Value //
		}
		return "no value";
	}
}
?>		
Return current item: Range Compare