How to remove smart quote and emdash in PHP and replace them with space and regular dash?

173 Views Asked by At

I have a string with smart quote and emdash. I don't want to remove any other special characters. I just want to remove only these two. I want it to be displayed at some places but not in others.Tried couple of solutions but nothing worked. How should I proceed? These are the option that I tried...

$pullquoteWithapos = utf8_encode($title);
$pullquoteWithapos =utf8_decode(str_replace('”','',$pullquoteWithapos));
$pullquoteWithapos = utf8_decode($pullquoteWithapos);
$pullquoteWithapos = str_replace('?', '\'',$pullquoteWithapos);
echo $pullquoteWithapos;

TIA


This is what I did which worked $cleanStr = htmlentities($str, ENT_QUOTES, 'UTF-8'); $cleanStr = str_replace('”','',$cleanStr); $cleanStr = str_replace('—','-',$cleanStr); $cleanStr = str_replace('’','\'', $cleanStr);

0

There are 0 best solutions below