djtozz Posted November 13, 2009 Share Posted November 13, 2009 Hi, I'm using a little scirpt that creates rss feeds for my mysql table. works fine, except for the records that have a "&" in my table. I've tried to following: $caption = str_replace("&","and",$caption); but this doesn't seems to work, can somebody help me with this please ? Are there maybe other functions out there that can do the same? (converting the 'illegal' characters from a variable to the right format for xml) Thanks, Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted November 13, 2009 Share Posted November 13, 2009 Try this. <?php $caption = "I ate fish & chips for dinner"; $replaceCharacter = str_replace("&","and",$caption); echo $replaceCharacter; ?> Quote Link to comment Share on other sites More sharing options...
thebadbad Posted November 13, 2009 Share Posted November 13, 2009 I think htmlspecialchars() would do the job (converting & to &). Quote Link to comment Share on other sites More sharing options...
Schlo_50 Posted November 13, 2009 Share Posted November 13, 2009 If it's another function you're after, you could even try preg_replace(). Quote Link to comment Share on other sites More sharing options...
djtozz Posted November 13, 2009 Author Share Posted November 13, 2009 Thanks guys, Schlo_50 : your solution worked for me, thank you Thebadbad: htmlspecialchars was exactly what I was looking for! Thanks a lot! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.