Non-Regex function to replace <br> with <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
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Non-Regex function to replace <br> with <br />?

Post by JAB Creations »

I'm currently looking for a non-regex function in PHP that will replace unclosed <br> elements with properly closed <br /> elements. I'd prefer to do this without using regex if at all possible. 8)
User avatar
onion2k
Jedi Mod
Posts: 5263
Joined: Tue Dec 21, 2004 5:03 pm
Location: usrlab.com

Re: Non-Regex function to replace <br> with <br />?

Post by onion2k »

What's wrong with str_replace()?
User avatar
JAB Creations
DevNet Resident
Posts: 2341
Joined: Thu Jan 13, 2005 6:44 pm
Location: Sarasota Florida
Contact:

Re: Non-Regex function to replace <br> with <br />?

Post by JAB Creations »

I was applying this to the wrong part of my script which is the only reason you beat me to post #2. :P

Code: Select all

$message_xml = str_replace("<br>", "<br />", $message);
Post Reply