[thelist] Linebreaks in PHP/MySQL newsletter

Keith Gaughan keith at digital-crew.com
Fri Jan 7 07:18:09 CST 2005


Mike wrote:
> Hi all
> 
> When I format newsletters using this code...
> 
> $nlText = wordwrap( $text,72 );
> 
> ... some users get all the text on one line.
> 
> If I replace 'bad' linebreaks like this:
> 
> $text = ereg_replace( "\r\n","\n",$text );
> $text = ereg_replace( "\r","\n",$text );
> $nlText = wordwrap( $text,72 );
> 
> ... some users get the newsletter with double linebreaks.
> 
> Of course, when I test it (Win2000, Win98, Eudora, Outlook, TheBat),
> everything looks good, in both cases.
> 
> Your advice/experience?

If the text is coming from a form, you should *always* be getting CRLFs
as your linebreaks. I'm not sure if that's the case, but if it is,
something odd's going on.

What might be happening is that the linebreaks might mixed. An example
of something that might result in a double linefeed would be a sequence
like "\r\n\n", where the second \n is being ignored (IE's textarea will
do this as it's the same control as makes up the body of notepad).

When converted, this leaves you with \n\n.

I'd check your incoming data to see if this is what's happening.

K.

-- 
Keith Gaughan, Developer
Digital Crew Ltd., Pembroke House, Pembroke Street, Cork, Ireland
http://digital-crew.com/


-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.300 / Virus Database: 265.6.9 - Release Date: 06/01/2005



More information about the thelist mailing list