The problem looks simple, but it's taking time to figure out. I need to get rid of ndash characters from some strings in a project. Not the HTML entity –, but the actual character ( – ). Using str_replace() and preg_replace() didn't work.
Already tried:
$new_str = str_replace('–', '', $str_with_ndash_char);
Also tried:
$new_str = preg_replace('/–/', '', $str_with_ndash_char);
Also, it's a legacy project. Some parts of it are iso-8859-1 encoded, and a few others are utf-8 encoded. I noticed that my editor (Komodo Edit) complains about the ndash character when a PHP file is iso-8859-1, losing the character when I save the file, like this:
$new_str = str_replace('?', '', $str_with_ndash_char);
Converting everything to utf-8 results in a lot of garbage characters (same for the other way around, converting everything to iso-8859-1), so I'm avoiding doing it unless it's really, really necessary.
Edited: removed double $ signs (bad CTRL+V).