Why <br />

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Why <br />

Post by patrikG »

nl2br keeps producing <br /> instead of simple <br> - not that I minded in the past, as both work, but now I have to summon up my very limited regEx-skills and find <br /> - which is just not as easy.

Why is it <br /> instead of <br>?
Does anyone know a nice simple regEx for <br />?
pootergeist
Forum Contributor
Posts: 273
Joined: Thu Feb 27, 2003 7:22 am
Location: UK

Post by pootergeist »

I don't know the regex, do know that <br /> is html4+ xhtml compliant though - all non-closing tags (ones without a <opener></closer> pair) in compliant code are closed prior to the greater-than symbol - eg <img .... /> etc
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you're using nl2br() then you don't have to do a regex to find <br /> if you're looking for end of lines - you can look for \n instead as the <br /> are just put next to the newline characters (\n) by nl2br().

Of course I don't know exactly what you need to match but if it is linebreaks then \n is the better and easier thing to search on.

Mac
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

Yep - it works now. Thanks a lot :)
Post Reply