Hi,
I have an array of objects. Each object has a property that is an int. I want to pick out of the array the object with the max for that particular property. Is there a smart way to do this?
I have an array of objects. Each object has a property that is an int. I want to pick out of the array the object with the max for that particular property. Is there a smart way to do this?
PHP:
class example
{
public $property;
private $otherProperty;
private $yetAnother;
}
$array[0] = new example;
$array[0]->property=10;
$array[1] = new example;
$array[1]->property=11;
(example)$maxItem = max($array->property)
//In this example it should return the item at $array[1]