Thanks. According to the manual, the <br /> is for XHTML compliance. This changed in 4.0.5.
-- Gaylen [EMAIL PROTECTED] Home http://www.gaylenandmargie.com PHP KISGB v2.3 Guestbook http://www.gaylenandmargie.com/phpwebsite "Liljim" <[EMAIL PROTECTED]> wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > Thinking about it, this would probably be even better: > > $string = preg_replace("/(\n|<br>){3,}/i", "\\1\\1\\1", $string); > > This: > $string = "This is a > \n\n\n\n\n\n\n\n\n\n\ntest\nTesting\nTesting\n\n123<br><br><br><br><br><br>< > br><br><br><br><br>Some more testing<br><br><br><br><br><br><br><br><br>And > a little > more<br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br><br> > <br><br><br><br><br><br><br><br><br><br><br><br><br><br>Even more."; > > Then outputs as this: > > This is a <br /> > <br /> > <br /> > test<br /> > Testing<br /> > Testing<br /> > <br /> > 123<br><br><br>Some more testing<br><br><br>And a little > more<br><br><br>Even more. > > when echo'd with nl2br() > > As a side note, does anyone know what's with the <br> tag changing to <br > />? That's the way I've always used the line break tag for wml pages, but > hadn't realised that it's being written that way for standard html now. Is > this a change in spec? > > James > > "Liljim" <[EMAIL PROTECTED]> wrote in message > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > Hello Gaylen, > > > > try this: > > > > $string = preg_replace("/\n{3,}/", "\n\n\n", $string); > > > > James > > > > "Gaylen Fraley" <[EMAIL PROTECTED]> wrote in message > > [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... > > > I need a routine that will allow me to trap multiple <br> and/or line > feed > > > characters and convert them to a constant number. As an example, let's > > say > > > that you have text that has 10 carriage returns and/or line feeds. I > want > > > to limit this to 3. So, I need to be able to parse the line to detect > the > > > multiple control characters and convert the string to 3. So if the > string > > > looked something like: > > > > > > This is \n\n\n\n\n\n\n\n\n\n a test. > > > > > > I would want it converted to > > > > > > This is \n\n\n a test. > > > > > > > > > Conceivably, it could be > > > > > > This is <br><br><br><br><br> a test. > > > > > > I would want it converted to > > > > > > This is <br><br><br> a test. > > > > > > > > > I know I could write a do/while loop, but I was wondering if there is a > > way > > > using eregi_replace or something along that line? > > > > > > Thanks! > > > > > > > > > > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]