Thursday, May 24, 2007

PHP-Text wrapper plus

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);
} ?>

Disclaimer: Any code or advice given is for instructional purposes only. We will not be responsible for any loss or damage caused by using this script.

No comments: