How can conditional statements be used to control the display of a "Read More" link based on text length in PHP?

To control the display of a "Read More" link based on text length in PHP, you can use conditional statements to check the length of the text. If the text exceeds a certain length, display the "Read More" link; otherwise, display the full text without the link.

<?php
$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.";

if(strlen($text) > 100){
    echo substr($text, 0, 100) . "... <a href='#'>Read More</a>";
} else {
    echo $text;
}
?>