Home >Backend Development >PHP Tutorial >Parse array splice to remove the value of the specified key in the array and return a new array_PHP tutorial
Usage environment: There is a resume confidentiality setting in the talent network project, which has a filter keyword. Only if the company name of a certain company contains one of the keywords, the resume will not be displayed. Of course , I haven’t gone there yet, now I need to add and delete keywords.
Imagine: No matter how many resumes a person has, all resumes are set to the same keyword filtering (mainly because there are very few people using them, so it doesn’t matter if stored like this, and it is easy to use when searching) Convenient), and then form all the keywords into a string separated by half-width commas.
Problem: When displaying, I convert the string into an array and then loop it out for display, but now I want to delete the specified keyword.
Solution: Since it is converted into an array, then if there is a value, there will be a key. I will pass the key to the delete page and delete the value of the specified key. .
Problem: How to delete the specified key value from the array? I only saw filtering, pushing, and popping, but not the built-in functions for removing the specified key value.
Now, this function has appeared, it is called array_splice, you can use it to easily remove the value of the specified key, and then return a new array
Code snippet: