The problem occurs when the function explode () is used. there is a string in the format of a set of keywords separated by commas. in PHP, you can use the function explode () to extract these keywords into an array and save them. an empty element may exist in the saved array. for example, when the initial string is:, Keyword 1, keyword 2 ,. how to remove them? Use Google to find the following two web pages to address... the problem is encountered when the function explode () is used.
There is a string in the format of a comma-separated keyword. in PHP, you can use the function
Explode (), extract these keywords into an array to save. the saved array may contain empty elements. for example, when
The initial string is ', Keyword 1, keyword 2 ,'.
How to remove them?
Google finds the following two web pages and describes how to use the array_filter () function to solve this problem.
1. PHP removes null values from the array
2. php function array_filter () filter php empty array _ php remove empty array _ array key name reset serialization
Of course, for the use of array_filter (), please refer to the document for more information.