How to get rid of ® and ? in the string? (PHP)

pigeoto

New Member
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:\[code\]$string = "Welcome to McDonalds?: I'm loving it?";$string = preg_replace('/[^a-zA-Z0-9 -]/', '', $string); \[/code\]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:\[code\]$string = preg_replace(array('/[^a-zA-Z0-9 -]/', '/&[^\s]*;/'), '', preg_replace(array('/&[^\s]*;/'), '', htmlentities($string)));\[/code\]
 
Back
Top