Thanks, it works now!
I used the following codes.
// Instance of new line (\r\n) with < br >
// Note, the received string from a text
// area may use different methods of
// symbolising the new line
$NEW_MESSAGE = str_replace("\r\n", " < br > ", $NEW_MESSAGE);
// Split it into the different words, if
// there to long word add a space then
// put all the words back into a new variable.
$SPLIT_NEW_MESSAGE = explode(" ", "$NEW_MESSAGE");
$NUMBER_OF_ELEMENTS = count($SPLIT_NEW_MESSAGE);
$COUNT = 0;
// Loop though all the words, if one is longer than
// 40 characters put in a space, then add this word
// to the variable containing the processed string
while ($COUNT <= $NUMBER_OF_ELEMENTS) {
$CURRENT_WORD = $SPLIT_NEW_MESSAGE[$COUNT];
$LENGTH_OF_WORD = strlen ($CURRENT_WORD);
if ($LENGTH_OF_WORD >= 40) {
$CURRENT_WORD = wordwrap( $CURRENT_WORD, 40, " ", 1);
}
$FINAL_NEW_MESSAGE .= "$CURRENT_WORD ";
$COUNT = $COUNT + 1;
}
// Now print out the finished string – you might want to
// store it in a database or do some other work to it.
Echo “$FINAL_NEW_MESSAGE”;