Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trouble Replacing Apostrophe with Preg_Replace

I am attempting to remove apostrophes from text and it isn't really working. It's got to be something small.

$text = preg_replace('/\'/', '', $text);

That's what I am using right now to remove it. What am I doing wrong?

There is a series of these to remove special characters to turn them into urls and store them in my database. However, a recent batch appeared with a ' where the ' was.

Any help is greatly appreciated. Thank you in advance.

like image 550
NotJay Avatar asked Oct 19 '11 14:10

NotJay


1 Answers

Have a go using str_replace(), it's quicker than preg_replace() since it doesn't use regular expressions.

$text = str_replace("'", '', $text);
like image 121
472084 Avatar answered Oct 03 '22 11:10

472084