0

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);

Srividhya
  • 113
  • 8
  • post what you have tried and we will help from there. – cmorrissey Jan 25 '16 at 19:33
  • I tried this.. But it didn't work either $search = array('”','—'); $replace = array('','-'); $var = str_replace($search, $replace, $var); echo $var; – Srividhya Jan 25 '16 at 20:06
  • Other code $pullquoteWithapos = utf8_encode($title); $pullquoteWithapos = utf8_decode(str_replace('”', '', $pullquoteWithapos)); $pullquoteWithapos = utf8_decode($pullquoteWithapos); $pullquoteWithapos = str_replace('?', '\'',$pullquoteWithapos); – Srividhya Jan 25 '16 at 20:08
  • might be a good chance to edit the question with the above comments. – bibi Jan 25 '16 at 20:14
  • This is what I which worked. $cleanStr = htmlentities($str, ENT_QUOTES, 'UTF-8'); $cleanStr = str_replace('”','',$cleanStr); $cleanStr = str_replace('—','-',$cleanStr); $cleanStr = str_replace('’','\'', $cleanStr); return $cleanStr; – Srividhya Jan 26 '16 at 17:07

0 Answers0