In the past few days, I encountered a small problem at work. There is a content type field that stores language. Because the data is imported from Excel, so in order to simplify the processing, many languages are separated by commas, and all languages are A string, which makes saving it much simpler. However, due to the problem of data quality at the beginning, some "Chinese" were "Mandarin Chinese", and now all "Mandarin Chinese" need to be changed to "Chinese".
This requires replacing part of a string. For such a problem, we usually use regular expressions to do the replacement, or use some replacement methods in PHP. It feels very troublesome to do this, and time is tight, so I thought of a lazy way, using the explode function. , use the string to be replaced as the delimiter, then connect the string to be replaced between the two array elements, and then UPDATE.