How to remove characters from a string in PHP

How can I strip unwanted characters / words from a PHP string? (Or, How can I remove or delete special characters from a PHP string?). Remove characters from a string in php function clean($string) { $string = str_replace(‘ ‘, ‘-‘, $string); // Replaces all spaces with hyphens. $string = preg_replace(‘/[^A-Za-z0-9\-]/’, ”, $string); // Removes special… Read More »