Question

What character does tinyMCE put in between empty p tags.

I have the following empty p tags:

<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>
<p> </p>

Which I'd like to remove... but they are not recognized by str_replace or preg_replace. The best I could do to track down the issue, is the space between the tags. In other words I can remove the

<p> 

by itself or the

</p>

... but when I try searching for

<p> </p> 

it doesn't find it.

Tried

&nbsp; 

or

&#32;

I found many solutions online but NONE work. It seems the character in question (the space between the p tags) is different or somehow not recognized. I say this because I tried the following

str_replace(" ", "", $html);

All of the other spaces in the string got deleted... EXCEPT for the space between the p tags.

Was it helpful?

Solution

It is probably some non-printing unicode character of some type. \s or maybe \pS.

preg_replace("@<p>[\pZ\pC]*</p>@u", "", $string);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top