Search code examples
phpregexunicode

replace   characters that are hidden in text


How to remove   (that are hidden) and SPACES in below text but

  • hold UNICODE characters
  • hold <br> tag

i tested:

  • i used trim($string) => NOT WORKED
  • i used str_replace('&nbsp;', '', $string) => NOT WORKED
  • i used some regex => NOT WORKED

                <br>تاريخ ورود: یکشنبه ۲۳ بهمن ماه ۱۳۹۰
    

UPDATE: Image of hidden   Thanks


Solution

  • This solution will work, I tested it:

    $string = htmlentities($content, null, 'utf-8');
    $content = str_replace("&nbsp;", "", $string);
    $content = html_entity_decode($content);