Can't remove special characters with str_replace

后端 未结 8 664
北荒
北荒 2020-12-07 04:00

I have a very trivial problem with str_replace.

I have a string with the En Dash character ( - ) like this:

I want to remove - the dash
相关标签:
8条回答
  • 2020-12-07 04:56

    To anyone who has tried all of the above but still having no joy then this worked for me (from a WordPress get_the_title() function)

    $new_string = str_replace('–', 'or', $string);
    
    0 讨论(0)
  • 2020-12-07 04:59

    Only this solution worked for me:

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