title: How to remove &nbsp; from a UTF-8 string?
body: <p>My database is returning some strings like:</p>
  
  <p><code>This&amp;nbsp;is&amp;nbsp;a&amp;nbsp;string</code></p>
  
  <p>This is a problem when the string is long enough and you have maximum width set:</p>
  
  <pre><code>&lt;p style="width:50px"&gt;This&amp;nbsp;is&amp;nbsp;a&amp;nbsp;string&lt;/p&gt;
  </code></pre>
  
  <p>In order to get ride of <code>&amp;nbsp;</code> entities I've tried to use the following filters without success:</p>
  
  <pre><code>$new = preg_replace("/&amp;nbsp;/i", " ", $str);
  $new = str_replace('&amp;nbsp;', ' ', $str);
  $new = html_entity_decode($str);
  </code></pre>
  
  <p>You have a <a href="http://phpfiddle.org/main/code/egs0-rf4n" rel="noreferrer">PHP fiddle to see this in action</a> (I've had to codify the string in hex from the database output; the string is in spanish, sorry).</p>
  
  <p>How to deal with this? Why <code>html_entity_decode()</code> is not working? And what about the replace functions? Thanks.</p>