What are the advantages of manually marking text truncation points rather than automating the process in PHP?

When manually marking text truncation points, the advantage is that you have full control over where the text should be truncated. This allows you to ensure that the text is truncated at logical points, such as the end of a sentence or before a certain character. Automating the process in PHP may not always accurately determine the best truncation points, potentially leading to awkward breaks in the text.

function truncateText($text, $length) {
    if (strlen($text) > $length) {
        $text = substr($text, 0, $length);
        $text = substr($text, 0, strrpos($text, ' '));
        $text .= '...';
    }
    return $text;
}

// Example usage
$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
echo truncateText($text, 20);