I'm limiting the number of characters in the title with substr. But even if the title is less than 50 characters, being shown the ellipsis (...). I would not display the ellipsis if the title does not exceed the limit of 50 characters.

$title = substr( $title, 0, 50 ) . "...";

Title of my post ...

(Incorrect: Title less than 50 characters in this case should not display "...")

Title of my post that exceeds 50 characters ...

(Correct: Title longer than 50 characters are cut and accompanied by "...")