Page 1 of 1

str_replace

Posted: Mon Jul 28, 2008 7:17 pm
by SidewinderX
So I have a small blog I often post snippets of code. Until now, I never realized when copied code from my IDE to my blogs WYSIWYG it would convert my quotes " into fancy quotes “

I tried to do an str_replace:

Code: Select all

$text = str_replace("“", '"', $text);
but that does not appear to work, it still renders the fancy quotes. How can I fix this?

Thanks,
John

Re: str_replace

Posted: Mon Jul 28, 2008 7:48 pm
by Christopher
This is from Chris Shiflett:

Code: Select all

function convert_smart_quotes($string) 
{ 
    $search = array(chr(145), 
                    chr(146), 
                    chr(147), 
                    chr(148), 
                    chr(151)); 
 
    $replace = array("'", 
                     "'", 
                     '"', 
                     '"', 
                     '-'); 
 
    return str_replace($search, $replace, $string); 
}