private function filterSpecialCharacters($string)
    {
        $string = str_replace('<', ' <',
            $string); // This is need, otherwise this: <h1>something</h1><h2>something</h2> will result in somethingsomething
        $string = strip_tags($string);
        $string = trim($string);
        $string = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $string); // Remove special alphanumeric characters
        $string = str_replace(array('+', '=', '!', ',', '.', ';', ':', '?'), ' ',
            $string); // Replace sentence breaking charaters with spaces
        $string = preg_replace("/[\r\n]+/", " ", $string); // Replace multiple newlines with a single space.
        $string = preg_replace("/[\t]+/", " ", $string); // Replace multiple tabs with a single space.
        $string = preg_replace("/[^a-zA-Z0-9 ]/", '',
            $string); // Filter out everything that is not alphanumeric or a space
        $string = preg_replace('!\s+!', ' ', $string); // Replace multiple spaces with a single space
        return $string;
    }
private function filterSpecialCharacters($string)
    {
        $string = str_replace('<', ' <',
            $string); // This is need, otherwise this: <h1>something</h1><h2>something</h2> will result in somethingsomething
        $string = strip_tags($string);
        $string = trim($string);
        $string = iconv('UTF-8', 'ASCII//TRANSLIT//IGNORE', $string); // Remove special alphanumeric characters
        $string = str_replace(array('+', '=', '!', ',', '.', ';', ':', '?'), ' ',
            $string); // Replace sentence breaking charaters with spaces
        $string = preg_replace("/[\r\n]+/", " ", $string); // Replace multiple newlines with a single space.
        $string = preg_replace("/[\t]+/", " ", $string); // Replace multiple tabs with a single space.
        $string = preg_replace("/[^a-zA-Z0-9 ]/", '',
            $string); // Filter out everything that is not alphanumeric or a space
        $string = preg_replace('!\s+!', ' ', $string); // Replace multiple spaces with a single space
        return $string;
    }
private function filterSpecialCharacters ( $ string ) { $ string = str_replace ( '<' , ' <' , $ string ) ; // This is need, otherwise this: <h1>something</h1><h2>something</h2> will result in somethingsomething $ string = strip_tags ( $ string ) ; $ string = trim ( $ string ) ; $ string = iconv ( 'UTF-8' , 'ASCII//TRANSLIT//IGNORE' , $ string ) ; // Remove special alphanumeric characters $ string = str_replace ( array ( '+' , '=' , '!' , ',' , '.' , ';' , ':' , '?' ) , ' ' , $ string ) ; // Replace sentence breaking charaters with spaces $ string = preg_replace ( "/[\r\n]+/" , " " , $ string ) ; // Replace multiple newlines with a single space. $ string = preg_replace ( "/[\t]+/" , " " , $ string ) ; // Replace multiple tabs with a single space. $ string = preg_replace ( "/[^a-zA-Z0-9 ]/" , '' , $ string ) ; // Filter out everything that is not alphanumeric or a space $ string = preg_replace ( '!\s+!' , ' ' , $ string ) ; // Replace multiple spaces with a single space return $ string ; }
Filter out all special characters, like punctuation and characters with accents

@param $string

@return mixed|string
Filter out all special characters like punctuation and characters with accents