Remove all non-alphanumeric characters using preg_replace February 23, 2023 by Tarik $url = preg_replace('/[^\da-z]/i', '', $string);