How can PHP be used to limit the number of characters displayed from a text retrieved from a database table?

To limit the number of characters displayed from a text retrieved from a database table in PHP, you can use the `substr()` function to extract a portion of the text based on a specified length. This allows you to control the number of characters displayed to the user, which can be useful for displaying previews or summaries of longer text content.

// Retrieve the text from the database
$text = $row['text_column'];

// Limit the number of characters displayed to 100
$limited_text = (strlen($text) > 100) ? substr($text, 0, 100) . '...' : $text;

// Output the limited text
echo $limited_text;