35 Votes

MySQL: Replace BR tags with line breaks

Tip by Progger99 | 2012-02-14 at 21:07

If we want to replace all HTML <br> tags with a line break (newline) directly in MySQL, we can simply use the following function:

UPDATE tab SET col = REPLACE(col, "<br>", "\r\n");

The advantage is obvious: We are performing the command directly in our MySQL database, so that we do not have to read out the data first to edit it in PHP only for re-entering it in our database again after the processing.

ReplyPositiveNegative

About the Author

AvatarThe author has not added a profile short description yet.
Show Profile

 

Related Topics

Important Note

Please note: The contributions published on askingbox.com are contributions of users and should not substitute professional advice. They are not verified by independents and do not necessarily reflect the opinion of askingbox.com. Learn more.

Participate

Ask your own question or write your own article on askingbox.com. That’s how it’s done.