Re: Anyone know of better way to convert the ASCII text to html text???
| From: | Scott Fletcher | Date: | Fri, 09 Apr 2004 15:35:59 +0000 |
| Subject: | Re: Anyone know of better way to convert the ASCII text to html text??? | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-11765@lists.php.net to get a copy of this message | ||
Never mind that! I finally understood what you meant with "space+ ";
So, I did this code but it's not perfect.
--snip--
$user_message = preg_replace('/\n/', '',$user_message);
$user_message = preg_replace('/\r/',
'<br>',$user_message);
//$user_message =
preg_replace("/\s/",' ',$user_message);
$userMsgArray = array();
$MsgLen = strlen($user_message);
for ($x=0;$x<$MsgLen;$x++) {
$UsrMsgArray[$x] = substr($user_message,$x,1);
if (($UsrMsgArray[$x-1] == " ")&&($UsrMsgArray[$x] == "
")) {
$UsrMsgArray[$x-1] = " ";
}
}
for ($x=0;$x<$MsgLen;$x++) {
$DoneUsrMsg .= $UsrMsgArray[$x];
}
//=====================================================================
echo $DoneUsrMsg;
--snip--
"Scott Fletcher" <scott@abcoa.com> wrote in message
news:20040408205623.81158.qmail@pb1.pair.com...
> > So, for what you are trying to do, you probably want to search on a
> > double space and replace it with a space+
> That sound reasonable. I'm not sure if I can make this work quickly
without
> making it taking some time to perform the task and slow down the website.
>
> FletchSOD