note 41133 added to function.split
| From: | alphibia at alphibia dot com | Date: | Wed, 31 Mar 2004 11:19:56 +0000 |
| Subject: | note 41133 added to function.split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-67411@lists.php.net to get a copy of this message | ||
I'd like to correct myself, I found that after testing my last solution it will create 5 lines
no matter what... So I added this to make sure that it only displays 5 if there are five newlines.
:-)
<?php
$MaxNewLines = 5;
$BRCount = substr_count($Message, '<br />');
if ($BRCount<$MaxNewLines)
$MaxNewLines=$BRCount;
else if($BRCount == 0)
$MaxNewLines=1;
$Message = str_replace(chr(13), "<br />", $Message);
$MessageArray = split("<br />", $Message, $MaxNewLines);
$Message = ""; $u=0;
do {
$Message.=$MessageArray[$u].'<br />';
$u++;
} while($u<($MaxNewLines-1));
$Message.=str_replace("<br />"," ",$MessageArray[$u]);
?>
-Tim
http://www.alphibia.com
----
Manual Page -- http://www.php.net/manual/en/function.split.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+41133
Delete -- http://master.php.net/manage/user-notes.php?action=delete+41133&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+41133&report=yes
Search -- http://master.php.net/manage/user-notes.php