How can I find the max attribute in an array of objects?
问题 How can I find the maximum value for the objects in my array? Say I have an array of objects like this: $data_points = [$point1, $point2, $point3]; where $point1 = new stdClass; $point1->value = 0.2; $point1->name = 'Bob'; $point2 = new stdClass; $point2->value = 1.2; $point2->name = 'Dave'; $point3 = new stdClass; $point3->value = 0.8; $point3->name = 'Steve'; I would like to do something like this: $max = max_attribute_in_array($data_points, 'value'); I know I can iterate over the array