Text
|
|
|
|
<?php function cleanup ($comment)
/*
string cleanup (string string);
Cleans up string into HTML compatable code.
Note: You may need to change nr to n.
*/ {
$comment = trim ($comment); // remove starting/trailing whitespace
for ($c = 1; $c <= 4; $c++)
$comment = str_replace ("nnn", "nn", $comment); // makes many lines into one.
$comment = str_replace ("n", '', nl2br ($comment)); // n to <br>
list ($words) = array (explode (' ', $comment)); // $words array formed
$comment = '';
foreach ($words as $c => $word) {
if (strlen ($word) > 60 and !ereg ("[[|]|//|.com]", $word))
$word = wordwrap ($word, 60, '<br>', 1);
$comment .= ' ' . $word;
}
$comment = str_replace (array ('<br> ', ' <br>', ' <br> '), '<br>', $comment);
return trim ($comment);
} ?>
|
|
|
Usage Example
|
|
|
Rate This Script
|
|
|
|