What potential issues can arise when using wordwrap in PHP to format text?

One potential issue that can arise when using wordwrap in PHP to format text is that it may break words in the middle if they are longer than the specified width. To solve this issue, you can use the wordwrap function with the 'cut' parameter set to true, which will cut the word at the specified width if it is too long.

$text = "This is a long word that needs to be wrapped";
$wrapped_text = wordwrap($text, 10, "\n", true);
echo $wrapped_text;