public function removeBadWords($string)
    {
        // read bad-word-table if not already read-in
        if (!$this->_badWordTable) {
            $this->_createBadWordTable();
        }

        // cut value into pieces
        $words = explode(' ', trim($string));

        // get replace character
        try {
            $replacecharacter = $this->getConfiguration()->words->replacecharacter;
        } catch (Doozr_Configuration_Service_Exception $exception) {
            $replacecharacter = '*';
        }

        // iterate over each word
        foreach ($words as $key => $word) {

            // clean word from special chars
            $word = preg_replace('/[^a-zA-Z0-9]+/', '', $word);

            foreach ($this->_badWordTable as $badWord) {
                if (preg_match('/^'.$badWord.'/im', $word)) {
                    $words[$key] = preg_replace(
                        '/^'.$badWord.'+/im',
                        str_repeat($replacecharacter, mb_strlen($badWord)),
                        $word
                    );
                    break;
                }
            }
        }

        // return the result
        $result = implode(' ', $words);

        return $result;
    }
public function removeBadWords($string)
    {
        // read bad-word-table if not already read-in
        if (!$this->_badWordTable) {
            $this->_createBadWordTable();
        }

        // cut value into pieces
        $words = explode(' ', trim($string));

        // get replace character
        try {
            $replacecharacter = $this->getConfiguration()->words->replacecharacter;
        } catch (Doozr_Configuration_Service_Exception $exception) {
            $replacecharacter = '*';
        }

        // iterate over each word
        foreach ($words as $key => $word) {

            // clean word from special chars
            $word = preg_replace('/[^a-zA-Z0-9]+/', '', $word);

            foreach ($this->_badWordTable as $badWord) {
                if (preg_match('/^'.$badWord.'/im', $word)) {
                    $words[$key] = preg_replace(
                        '/^'.$badWord.'+/im',
                        str_repeat($replacecharacter, mb_strlen($badWord)),
                        $word
                    );
                    break;
                }
            }
        }

        // return the result
        $result = implode(' ', $words);

        return $result;
    }
public function removeBadWords ( $ string ) { // read bad-word-table if not already read-in if ( ! $ this -> _badWordTable ) { $ this -> _createBadWordTable ( ) ; } // cut value into pieces $ words = explode ( ' ' , trim ( $ string ) ) ; // get replace character try { $ replacecharacter = $ this -> getConfiguration ( ) -> words -> replacecharacter ; } catch ( Doozr_Configuration_Service_Exception $ exception ) { $ replacecharacter = '*' ; } // iterate over each word foreach ( $ words as $ key => $ word ) { // clean word from special chars $ word = preg_replace ( '/[^a-zA-Z0-9]+/' , '' , $ word ) ; foreach ( $ this -> _badWordTable as $ badWord ) { if ( preg_match ( '/^' . $ badWord . '/im' , $ word ) ) { $ words [ $ key ] = preg_replace ( '/^' . $ badWord . '+/im' , str_repeat ( $ replacecharacter , mb_strlen ( $ badWord ) ) , $ word ) ; break ; } } } // return the result $ result = implode ( ' ' , $ words ) ; return $ result ; }
This method is intend to remove a bad-word from a given string.

@param string $string The string to check for containing bad-word

@author Benjamin Carl <opensource@clickalicious.de>

@return string The replaced value if bad-word found, otherwise the original-input
This method is intend to remove a bad - word from a given string .