I have a string with “\u00a0”, and I need to replace it with “” str_replace fails

后端 未结 8 1215
南笙
南笙 2020-12-17 09:45

I need to clean a string that comes (copy/pasted) from various Microsoft Office suite applications (Excel, Access, and Word), each with its own set of encoding.

I\'m

相关标签:
8条回答
  • 2020-12-17 10:19

    This one also works, i found somewhere

    $str = trim($str, chr(0xC2).chr(0xA0));
    
    0 讨论(0)
  • 2020-12-17 10:20

    You have to do this with single quotes like this:

    str_replace('\u00a0', "",$string);
    

    Or, if you like to use double quotes, you have to escape the backslash - which would look like this:

    str_replace("\\u00a0", "",$string);
    
    0 讨论(0)
提交回复
热议问题