AnsPress_Bad_words::find_bad_words( string $str )

Description #

Find bad words in a string.

Parameters #

  • $str
    string (Required) String need to be checked.

Source #

File: addons/free/bad-words.php

	public static function find_bad_words( $str ) {
		$found = array();

		foreach ( (array) SELF::get_bad_words() as $w ) {
			$w = trim( $w );
			$count = preg_match_all( '/\b' . preg_quote( $w,'/' ) . '\b/i', $str );

			if ( $count > 0 ) {
				$found[ $w ] = $count;
			}
		}

		if ( ! empty( $found ) ) {
			return $found;
		}

		return false;
	}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment