Remove all non-alphanumeric characters using preg_replace
php, preg-replace, regex
Solution
$url = preg_replace('/[^\da-z]/i', '', $string);
Problem
How can I remove all non alphanumeric characters from a string in PHP? This is the code, that I'm currently using: ``` $url = preg_replace('/\s+/', '', $string); ``` It only replaces blank spaces.