What are some common methods for implementing a bad word filter in PHP registration forms?

When creating registration forms in PHP, it's important to implement a bad word filter to prevent users from entering inappropriate language. One common method is to create an array of banned words and then check user input against this array. If a match is found, the user should be prompted to enter a different word.

// Array of banned words
$bannedWords = array("badword1", "badword2", "badword3");

// Check user input against banned words
$userInput = $_POST['input_field'];
foreach($bannedWords as $word) {
    if (stripos($userInput, $word) !== false) {
        echo "Please do not use inappropriate language.";
        // Additional actions like clearing the input field or displaying an error message can be implemented here
        break;
    }
}