replace   characters that are hidden in text

后端 未结 4 551
傲寒
傲寒 2020-12-07 13:35

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

  • hold UNICODE characters
  • hold
    tag
4条回答
  •  长情又很酷
    2020-12-07 13:42

    Not tested, but if you use something like:

    $string = preg_replace("/\s/",'',$string);
    

    That should remove all spaces.

    UPDATE

    To remove all spaces and   references, use something like:

    $string = preg_replace("/\s| /",'',$string);
    

    UPDATE 2

    Try this:

    $string = html_entity_decode($string);
    
    $string = preg_replace("/\s/",'',$string);
    
    echo $string;
    

    Forgot to say, reconvert the html entities so add this after the replacement:

    htmlentities($string);
    

提交回复
热议问题