Most answers here are about converting line breaks to <p>
but I’m looking to do the opposite. I need <p>
to be rnrn
.
Because the WCFM marketplace plugin for WordPress is forcing the use of HTML elements but I need to output my description as JSON object as below, without HTML.
{
"name": "Hijo",
"description": "<p>Too cute to avoid. You'd so wanna bring her home.</p><p>Each of our pets is .....",
}
Or is there an opposite function to wpautop()?
2
Answers
you can use preg_match function to find and replace the
<p>
withrn
, an</p>
with blank spaceYou can just use strtr to swap the strings.
Note: The special characters like n must be in double quotes.
Output: