I wrote this function because php's wordwrap() doesn't fit the needs of a regular web page. Just enter for this function the string, the row limit and if you like the divider. This function breaks the line after the character limit is reached.
<?php function text_wrap($log_text, $limit, $divider=" ") { $words = explode($divider, $log_text); $word_count = count($words); $char_counter = 0; $block = ""; foreach ($words as $value) { $chars = strlen($value); $block .= $value; $char_counter = $char_counter + $chars; if ($char_counter >= $limit) { $block .= " \\n "; $char_counter = 0; } else { $block .= " "; } } return rtrim($block); } // usage: echo text_wrap($some_text_with_100chars, 25, " "); // this function call will produce 4 rows of text (maybe more) ?>