The problem is encountered when using the function explode().
There is a string whose format is a set of keywords separated by commas. In PHP, you can use the function
explode() to combine these keywords Extract it into an array and save it. There may be empty elements in the saved array, for example, when the initial string is: ',keyword 1,,keyword 2,'.
How to remove them?
Through Google, I found the following two web articles about using the function array_filter() to solve this problem.
1. PHP removes empty values in the array
2. The php function array_filter() filters the php empty array_php removes the empty array_array Key name reset serialization
Of course, for the use of array_filter(), you should read the documentation for more information.