How to split a long string without breaking words?

The easiest solution is to use wordwrap(), and explode() on the new line, like so:

$array = explode( "\n", wordwrap( $str, $x));

Where $x is a number of characters to wrap the string on.

Leave a Comment