..... if($object->some_recursive_call > $value){ $value = $object->some_recursive_call; } .....