View Single Post
Old 10-15-2005, 03:35 PM  
nakki
Confirmed User
 
Join Date: May 2001
Location: http://topadultblogs.com/
Posts: 137
Hey, this is how I'd do it:

Code:
/*
 * Gets the name of the member variable with the highest value
 *
 * Returns the name of the variable or false on failure
 */
function getHighestVariableName($obj) {
	if (!is_object($obj)) return false;
	
	// get all the variables of the class
	$values = get_object_vars($obj);
		
	$field = false;
	$highest = null;
	
	// loop through the variables, try to find the highest one
	foreach ($values as $key => $value) {
		if ($value > $highest) {
			$highest = $value;
			$field = $key;
		}
	}
	
	return $field;
}
Of course, this won't work if you only want to count certain member variables, not all of them. But I'm sure it could be modified to do that too. :]
__________________
- adult blog aggregator - sign up here
NastyLittle.com - trade with an established adult blog
nakki is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote