Hello!
I have a string like "Welcome to McDonalds®: I'm loving it™"... I want to get rid of ":", "'", ® and ™ symbols, so I do the following:
$string = "Welcome to McDonalds®: I'm loving it™";
$string = preg_replace('/[^a-zA-Z0-9 -]/', '', $string);
BUT on the output I receive:
"Welcome to McDonaldsreg Im loving ittrade"... so preg_replace somehow converts ® to 'reg' and ™ to 'trade', which is not good for me and I can't understand, why is such conversion happens at all. How do I get rid of this conversion?
SOLVED: Thanks for ideas, guys. I solved the problem:
$string = preg_replace(array('/[^a-zA-Z0-9 -]/', '/&[^\s]*;/'), '', preg_replace(array('/&[^\s]*;/'), '', htmlentities($string)));