替换字符串中的html标记[重复]

This question already has an answer here:

How can I replace html elements in strings which have mixed content such as:

$str = "Find the   element in this string";

I'd like to clear all &nbsp ; elements in the string. So, I tried:

str_replace(" ", " ", $str);

I know that &nbsp ; is space and renders as empty space, however there is a specific reason I need to do that related to other DB operations i have.

If str_replace doesn't work for HTML tags, should I use regular expressions?

</div>
$str = htmlentities($string, null, 'utf-8');
$str = str_replace("&nbsp;", "", $str);