title: Remove Unicode Zero Width Space PHP
body: <p>I have a text in Burmese language, UTF-8.  I am using PHP to work with the text.  At some point along the way, some ZWSPs have crept in and I would like to remove them.  I have tried two different ways of removing the characters, and neither seems to work.</p>
  
  <p>First I have tried to use:</p>
  
  <pre><code>  $newBody = str_replace("&amp;#8203;", "", $newBody);
  </code></pre>
  
  <p>to search for the HTML entity and remove it, as this is how it appears under Web Inspector.  The spaces don't get removed.  I have also tried it as:</p>
  
  <pre><code>  $newBody = str_replace("&amp;#8203", "", $newBody);
  </code></pre>
  
  <p>and get the same no result.</p>
  
  <p>The second method I tried was found on this question <a href="https://stackoverflow.com/questions/13481688/remove-zero-width-non-joiner-character-from-a-string-in-php">Remove ZERO WIDTH NON-JOINER character from a string in PHP</a></p>
  
  <p>which looked like this:</p>
  
  <pre><code> $newBody = str_replace("\xE2\x80\x8C", "", $newBody);
  </code></pre>
  
  <p>but I also got no result.  The ZWSP was not removed.</p>
  
  <pre><code>An example word in the text ($newBody) looks like this : ယူ​&amp;#8203;က​&amp;#8203;ရိန်
  And I want to make it look like this : ယူကရိန်း
  </code></pre>
  
  <p>Any ideas?  Would a preg_replace work better somehow?</p>
  
  <p>So I did try </p>
  
  <pre><code>$newBody = preg_replace("/\xE2\x80\x8B/", "", $newBody);
  </code></pre>
  
  <p>and it appears to be workings, but now there is another issue.</p>
  
  <pre><code>&lt;a class="defined" title="Ukraine"&gt;ယူ&amp;#8203;က&amp;#8203;ရိန်း&lt;/a&gt;
  </code></pre>
  
  <p>gets transformed into </p>
  
  <pre><code>&lt;a class="defined _tt_t_" title="Ukraine" style="font-family: 'Masterpiece Uni Sans', TharLon, Myanmar3, Yunghkio, Padauk, Parabaik, 'WinUni Innwa', 'Win Uni Innwa', 'MyMyanmar Unicode', Panglong, 'Myanmar Sangam MN', 'Myanmar MN';"&gt;ယူကရိန်း&lt;/a&gt;
  </code></pre>
  
  <p>I don't want it to add all that extra stuff.  Any ideas why this is happening?  Apart from coming up with some way to target only the text in between  , is there another way to prevent the preg_replace from adding all this extra stuff?  Btw, using google chrome on a mac.  It seems to act a bit differently with firefox...</p>