PHP re-order key in array after filter

We are usually do the filter in PHP array manually and get out some elements what are not needed any more. Let ‘s get an example then we will see the problem.

php array order

Now we will make a filter what we will remove the element value “b” out of the array so the array will return like this

But what we want is

So here is what we need to do to make it re-order the key

That ‘s it. It ‘s quite easy.

Leave a Reply

Your email address will not be published. Required fields are marked *

*