Can't remove special characters with str_replace

后端 未结 8 691
北荒
北荒 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:43

    Try this:

    $new_string = str_replace('–','',$string);
    

    Or:

    $new_string = str_replace(html_entity_decode('–'),'',$string);
    

    It is basically same as:

    $new_string = str_replace ('-','',$string);
    

提交回复
热议问题