Defining a string filtering function in PHP

In the course of PHP website development, you often have to filter comments or article content. It can be controlled in the backend, with the frontend calling the database, so that filtering of the submitted data can be modified in time. The principle I’ve come across here is to keep the banned phrases in an array, use a split function to break the array apart, and then use a regular expression function to test the banned phrases. php filter