Are there any built-in PHP functions or libraries that can help with limiting character count while preserving word integrity in a string?

When limiting character count in a string, it is important to preserve word integrity so that words are not cut off in the middle. One way to achieve this is by using the `wordwrap()` function in PHP, which wraps a string to a given number of characters while preserving whole words. By combining `wordwrap()` with `substr()` function, we can limit the character count of a string while ensuring that words are not split.

$string = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
$limitedString = wordwrap($string, 20, "\n");
$limitedString = substr($limitedString, 0, strpos($limitedString, "\n"));
echo $limitedString;