PHP has a function built in for doing this:
http://www.php.net/manual/en/function.wordwrap.php
$mystring = "hundres of millions of billions of characters";
$mystring = wordwrap($mystring,50,'\n');
breaks your string every 50 characters and places '\n' newline at the end of lines (well... to the nearest word anyways.... add the 'cut' argument onto the end to always wrap at 50 characters.... read manual if I confuse you 🙂
One liner works very well 😉