Page 1 of 1

Converting Smart Quotes for PHP

Posted: Tue Oct 03, 2006 3:57 pm
by elHelgo
I am trying to write an XML file as PHP. This is not valid however because of the smart quotes from the db. This is the ’ character. I've looked all over, but I can't find a single script that will find that character on my site and convert it to a character like '.

Any help on converting the smart quote would be greatly appreciated.

Thanks,
elHelgo

Posted: Tue Oct 03, 2006 9:14 pm
by waradmin
When you echo it what does it come up as? The special one or the normal ( ' ) one?

Posted: Wed Oct 04, 2006 12:16 pm
by elHelgo
It comes out as the special one. It can be seen here:

http://si.unl.edu/yearoneunl/feed.xml

Don't think it's because it's xml, there is a switch in apache that will let it output as php. I'm running a bunch of php code inside, that is not the problem. The problem is still trying to remove those special characters.

-elHelgo

Posted: Wed Oct 04, 2006 12:24 pm
by sam159
mabey this will work

Code: Select all

<?php
$var = ereg_replace("’","'",$var);
?>

Posted: Wed Oct 04, 2006 12:31 pm
by Luke
or

Code: Select all

str_replace('’', "'", $content);

Posted: Wed Oct 04, 2006 1:25 pm
by elHelgo
the ere_replace did the trick while the str_replace was not catching it. thanks.

-elHelgo

Posted: Wed Oct 04, 2006 1:30 pm
by Luke
should work now... I used the wrong character.