How can PHP automatically format text to include line breaks after a certain number of characters?

To automatically format text to include line breaks after a certain number of characters in PHP, you can use the `wordwrap()` function. This function wraps a string to a given number of characters, breaking the line at whitespace. By specifying the desired line length, you can control where the line breaks occur in the text.

$text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.";
$wrapped_text = wordwrap($text, 30, "\n", true);
echo $wrapped_text;