str_replace

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SidewinderX
Forum Contributor
Posts: 407
Joined: Fri Jul 16, 2004 9:04 pm
Location: NY

str_replace

Post 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
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: str_replace

Post 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); 
}
(#10850)
Post Reply