Converting Smart Quotes for PHP

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
elHelgo
Forum Newbie
Posts: 9
Joined: Tue Oct 03, 2006 3:52 pm

Converting Smart Quotes for PHP

Post 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
User avatar
waradmin
Forum Contributor
Posts: 240
Joined: Fri Nov 04, 2005 2:57 pm

Post by waradmin »

When you echo it what does it come up as? The special one or the normal ( ' ) one?
elHelgo
Forum Newbie
Posts: 9
Joined: Tue Oct 03, 2006 3:52 pm

Post 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
sam159
Forum Newbie
Posts: 5
Joined: Wed Oct 04, 2006 11:09 am
Location: Hull, UK

Post by sam159 »

mabey this will work

Code: Select all

<?php
$var = ereg_replace("’","'",$var);
?>
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

or

Code: Select all

str_replace('’', "'", $content);
Last edited by Luke on Wed Oct 04, 2006 1:30 pm, edited 1 time in total.
elHelgo
Forum Newbie
Posts: 9
Joined: Tue Oct 03, 2006 3:52 pm

Post by elHelgo »

the ere_replace did the trick while the str_replace was not catching it. thanks.

-elHelgo
User avatar
Luke
The Ninja Space Mod
Posts: 6424
Joined: Fri Aug 05, 2005 1:53 pm
Location: Paradise, CA

Post by Luke »

should work now... I used the wrong character.
Post Reply