We just released some code to make our software a little bit more user friendly, and it backfired. Basically, we're attempting to replace newlines with <br />
tags. The trouble is, sometimes our users will enter code like the following:
<a
href='http://nowhere.com'>Nowhere</a>
When we run our code, this translates to
<a <br />href='http://nowhere.com' />Nowhere</a>
which obviously doesn't render properly.
Is there a regular expression or a PHP function to strip, or perhaps compress, the whitespace between the attributes of an HTML tag?
Clarification: This isn't full HTML. It's more similar to Markdown or some other language (we will eventually be moving to Markdown, but I need a quick fix). So I can't just parse this as regular HTML. The newlines need to be converted to <br />
tags properly.