What are the potential pitfalls or issues to watch out for when truncating text in PHP?

One potential pitfall when truncating text in PHP is not accounting for HTML tags or entities within the text, which can result in broken HTML markup or display issues. To solve this, you can use the `strip_tags` function to remove any HTML tags before truncating the text.

$text = "<p>This is some <strong>sample</strong> text.</p>";
$truncated_text = substr(strip_tags($text), 0, 20);
echo $truncated_text;