How can I remove certain items of an array?
Let’s say I have an array with 10 elements, I want to remove elements at index 0, 3, and 8.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
unset()supports removing individual array elements. The order of the remaining elements isn’t affected.To reindex the array, simply call
array_values()on it. Order is still maintained until you call a sorting function on it; this just reindexes: