gdfhghjdfghgfhf Posted May 17, 2008 Share Posted May 17, 2008 just a simple question i would like to replace all single quotes ' with this character ` in the variable $text what syntax can i use to do this with str_replace? thanks Quote Link to comment Share on other sites More sharing options...
networkthis Posted May 17, 2008 Share Posted May 17, 2008 $quotes = ereg_replace("[^']", "`", $quotes ); Quote Link to comment Share on other sites More sharing options...
corbin Posted May 17, 2008 Share Posted May 17, 2008 str_replace will be considerably faster than a function that employes regular expressions. $text = "corbin's sentence"; echo str_replace('\'', '`', $text); //corbin`s sentence Quote Link to comment Share on other sites More sharing options...
corbin Posted May 17, 2008 Share Posted May 17, 2008 Hrmmm.... By the way, networkthis's code has an error. The pattern [^'] means any character that is not '. So, you would really want to remove the ^. 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.